From 100501ba7269faa0830e1c6804e5d4b9f0cbf1b5 Mon Sep 17 00:00:00 2001 From: Rikaard Hosein Date: Wed, 21 Sep 2016 09:37:42 -0400 Subject: [PATCH] statsd input plugin correctly handles colons in data-dog tag values now (#1794) * Code correctly handles colons in tag values now * Modified existing datadog tag test to include a tag value containing a colon --- plugins/inputs/statsd/statsd.go | 2 +- plugins/inputs/statsd/statsd_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/statsd/statsd.go b/plugins/inputs/statsd/statsd.go index 6e72e632f..555f6d45b 100644 --- a/plugins/inputs/statsd/statsd.go +++ b/plugins/inputs/statsd/statsd.go @@ -348,7 +348,7 @@ func (s *Statsd) parseStatsdLine(line string) error { tagstr := segment[1:] tags := strings.Split(tagstr, ",") for _, tag := range tags { - ts := strings.Split(tag, ":") + ts := strings.SplitN(tag, ":", 2) var k, v string switch len(ts) { case 1: diff --git a/plugins/inputs/statsd/statsd_test.go b/plugins/inputs/statsd/statsd_test.go index 3102030fe..bb0d68c16 100644 --- a/plugins/inputs/statsd/statsd_test.go +++ b/plugins/inputs/statsd/statsd_test.go @@ -693,7 +693,7 @@ func TestParse_DataDogTags(t *testing.T) { s.ParseDataDogTags = true lines := []string{ - "my_counter:1|c|#host:localhost,environment:prod", + "my_counter:1|c|#host:localhost,environment:prod,endpoint:/:tenant?/oauth/ro", "my_gauge:10.1|g|#live", "my_set:1|s|#host:localhost", "my_timer:3|ms|@0.1|#live,host:localhost", @@ -703,6 +703,7 @@ func TestParse_DataDogTags(t *testing.T) { "my_counter": map[string]string{ "host": "localhost", "environment": "prod", + "endpoint": "/:tenant?/oauth/ro", }, "my_gauge": map[string]string{