From d3d1bc72cac49a582eacd85e5d87f10f11e05988 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Fri, 20 Apr 2018 18:39:31 -0700 Subject: [PATCH] Fix duplicate tags when overriding tag (#4056) --- metric/metric.go | 1 + metric/metric_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/metric/metric.go b/metric/metric.go index 2c8fdb9c9..3249b56ad 100644 --- a/metric/metric.go +++ b/metric/metric.go @@ -123,6 +123,7 @@ func (m *metric) AddTag(key, value string) { if key == tag.Key { tag.Value = value + return } m.tags = append(m.tags, nil) diff --git a/metric/metric_test.go b/metric/metric_test.go index 1fecf2e44..47d44f3ef 100644 --- a/metric/metric_test.go +++ b/metric/metric_test.go @@ -63,6 +63,7 @@ func TestAddTagOverwrites(t *testing.T) { value, ok := m.GetTag("host") require.True(t, ok) require.Equal(t, "example.org", value) + require.Equal(t, 1, len(m.TagList())) } func TestRemoveTagNoEffectOnMissingTags(t *testing.T) {