From 2c61e5d3a5c65b15370d96f9086f29c5b6554fb9 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Wed, 21 Jun 2017 16:24:23 -0700 Subject: [PATCH] Use strings.Join in statsd input (#2947) --- plugins/inputs/statsd/statsd.go | 5 +++-- plugins/inputs/statsd/statsd_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/inputs/statsd/statsd.go b/plugins/inputs/statsd/statsd.go index d2c627b8a..144a3675f 100644 --- a/plugins/inputs/statsd/statsd.go +++ b/plugins/inputs/statsd/statsd.go @@ -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) } diff --git a/plugins/inputs/statsd/statsd_test.go b/plugins/inputs/statsd/statsd_test.go index ff3002d2c..486c6cece 100644 --- a/plugins/inputs/statsd/statsd_test.go +++ b/plugins/inputs/statsd/statsd_test.go @@ -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 {