From acc84a629a5752025fd26f460783cdf52f7afd30 Mon Sep 17 00:00:00 2001 From: Loren Howard Date: Mon, 10 Sep 2018 16:30:31 -0700 Subject: [PATCH] convert periods in tag values to underscore (#44) --- tags.go | 2 +- tags_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tags.go b/tags.go index 972ead2..f1e50ba 100644 --- a/tags.go +++ b/tags.go @@ -14,7 +14,7 @@ const ( ) // illegalTagValueChars are loosely set to ensure we don't have statsd parse errors. -var illegalTagValueChars = regexp.MustCompile(`[:|]`) +var illegalTagValueChars = regexp.MustCompile(`[:|.]`) type tagPair struct { dimension string diff --git a/tags_test.go b/tags_test.go index fc742a5..43379b6 100644 --- a/tags_test.go +++ b/tags_test.go @@ -27,3 +27,11 @@ func TestSerializeIllegalTags(t *testing.T) { t.Errorf("Serialized output (%s) didn't match expected output", serialized) } } + +func TestSerializeTagValuePeriod(t *testing.T) { + tags := map[string]string{"foo": "blah.blah", "q": "p"} + serialized := serializeTags(tags) + if serialized != ".__foo=blah_blah.__q=p" { + t.Errorf("Serialized output (%s) didn't match expected output", serialized) + } +}