Skip to content

Commit

Permalink
Use strings.Join in statsd input (#2947)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored Jun 21, 2017
1 parent 364da9a commit 82a04d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions plugins/inputs/statsd/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,11 @@ func (s *Statsd) parseStatsdLine(line string) error {
// Make a unique key for the measurement name/tags
var tg []string
for k, v := range m.tags {
tg = append(tg, fmt.Sprintf("%s=%s", k, v))
tg = append(tg, k+"="+v)
}
sort.Strings(tg)
m.hash = fmt.Sprintf("%s%s", strings.Join(tg, ""), m.name)
tg = append(tg, m.name)
m.hash = strings.Join(tg, "")

s.aggregate(m)
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/statsd/statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ func TestParse_MeasurementsWithMultipleValues(t *testing.T) {
// plus the last bit of value 1
// which adds up to 12 individual datapoints to be cached
if cachedtiming.fields[defaultFieldName].n != 12 {
t.Errorf("Expected 11 additions, got %d", cachedtiming.fields[defaultFieldName].n)
t.Errorf("Expected 12 additions, got %d", cachedtiming.fields[defaultFieldName].n)
}

if cachedtiming.fields[defaultFieldName].upper != 1 {
Expand Down

0 comments on commit 82a04d9

Please sign in to comment.