Use strings.Join in statsd input (#2947)

This commit is contained in:
Daniel Nelson 2017-06-21 16:24:23 -07:00 committed by GitHub
parent 364da9a83d
commit 82a04d904d
2 changed files with 4 additions and 3 deletions

View File

@ -475,10 +475,11 @@ func (s *Statsd) parseStatsdLine(line string) error {
// Make a unique key for the measurement name/tags // Make a unique key for the measurement name/tags
var tg []string var tg []string
for k, v := range m.tags { for k, v := range m.tags {
tg = append(tg, fmt.Sprintf("%s=%s", k, v)) tg = append(tg, k+"="+v)
} }
sort.Strings(tg) 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) s.aggregate(m)
} }

View File

@ -929,7 +929,7 @@ func TestParse_MeasurementsWithMultipleValues(t *testing.T) {
// plus the last bit of value 1 // plus the last bit of value 1
// which adds up to 12 individual datapoints to be cached // which adds up to 12 individual datapoints to be cached
if cachedtiming.fields[defaultFieldName].n != 12 { 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 { if cachedtiming.fields[defaultFieldName].upper != 1 {