Skip to content

Commit 282b0f4

Browse files
authored
Merge pull request #171 from m-lab/parser-fix
Add more metrics logging, onlyIfNull -> overwrite
2 parents 756afdc + e99c309 commit 282b0f4

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

parser/ndt.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,9 @@ func (n *NDTParser) fixValues(r schema.Web100ValueMap) {
575575
// snapshot addresses are always authoritative. Other sources don't handle
576576
// ipv6 correctly. So, always substitute, unless for some reason the snapshot
577577
// value is missing.
578-
logEntry.SubstituteString(false, []string{"connection_spec", "local_ip"},
578+
logEntry.SubstituteString(true, []string{"connection_spec", "local_ip"},
579579
[]string{"snap", "LocalAddress"})
580-
logEntry.SubstituteString(false, []string{"connection_spec", "remote_ip"},
580+
logEntry.SubstituteString(true, []string{"connection_spec", "remote_ip"},
581581
[]string{"snap", "RemAddress"})
582582

583583
// Handle local_af.
@@ -599,13 +599,13 @@ func (n *NDTParser) fixValues(r schema.Web100ValueMap) {
599599
// file is missing, they may be empty. In that case, we replace them
600600
// with values from the log entry, (which usually come from the snapshot.)
601601
// TODO - make these the ONLY representation of client/server tuple.
602-
r.SubstituteString(true, []string{"connection_spec", "server_ip"},
602+
r.SubstituteString(false, []string{"connection_spec", "server_ip"},
603603
[]string{"web100_log_entry", "connection_spec", "local_ip"})
604-
r.SubstituteInt64(true, []string{"connection_spec", "server_af"},
604+
r.SubstituteInt64(false, []string{"connection_spec", "server_af"},
605605
[]string{"web100_log_entry", "connection_spec", "local_af"})
606-
r.SubstituteString(true, []string{"connection_spec", "client_ip"},
606+
r.SubstituteString(false, []string{"connection_spec", "client_ip"},
607607
[]string{"web100_log_entry", "connection_spec", "remote_ip"})
608-
r.SubstituteInt64(true, []string{"connection_spec", "client_af"},
608+
r.SubstituteInt64(false, []string{"connection_spec", "client_af"},
609609
[]string{"web100_log_entry", "connection_spec", "local_af"})
610610

611611
start, ok := snap.GetInt64([]string{"StartTimeStamp"})

schema/web100.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,16 @@ func (s Web100ValueMap) SetString(name string, value string) {
8585
s[name] = value
8686
}
8787

88-
func (r Web100ValueMap) SubstituteString(onlyIfNull bool, target []string, source []string) {
88+
// if overwrite is false, will only add missing values.
89+
// if overwrite is true, will overwrite existing values.
90+
func (r Web100ValueMap) SubstituteString(overwrite bool, target []string, source []string) {
8991
m := r.GetMap(target[:len(target)-1])
9092
if m == nil {
9193
// Error ?
9294
log.Printf("No such path: %v\n", target)
9395
return
9496
}
95-
if _, notNull := m[target[len(target)-1]]; onlyIfNull && notNull {
97+
if _, notNull := m[target[len(target)-1]]; notNull && !overwrite {
9698
// All good
9799
return
98100
}
@@ -104,14 +106,16 @@ func (r Web100ValueMap) SubstituteString(onlyIfNull bool, target []string, sourc
104106
m[target[len(target)-1]] = value
105107
}
106108

107-
func (r Web100ValueMap) SubstituteInt64(onlyIfNull bool, target []string, source []string) {
109+
// if overwrite is false, will only add missing values.
110+
// if overwrite is true, will overwrite existing values.
111+
func (r Web100ValueMap) SubstituteInt64(overwrite bool, target []string, source []string) {
108112
m := r.GetMap(target[:len(target)-1])
109113
if m == nil {
110114
// Error ?
111115
log.Printf("No such path: %v\n", target)
112116
return
113117
}
114-
if _, notNull := m[target[len(target)-1]]; onlyIfNull && notNull {
118+
if _, notNull := m[target[len(target)-1]]; notNull && !overwrite {
115119
// All good
116120
return
117121
}

0 commit comments

Comments
 (0)