From 82a04d904debdabfc569e8d5b704de81d9bdd5bb Mon Sep 17 00:00:00 2001
From: Daniel Nelson <daniel@wavesofdawn.com>
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 d2c627b8..144a3675 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 ff3002d2..486c6cec 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 {
-- 
GitLab