From ba709b47489ad215edb2ac3e7712e67c76a85454 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) (cherry picked from commit ee9a2f73a1dd8cca607d11f546b7281b03b70452) --- 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) {