Fix duplicate tags when overriding tag (#4056)

This commit is contained in:
Daniel Nelson 2018-04-20 18:39:31 -07:00 committed by GitHub
parent 3440d70f5c
commit d3d1bc72ca
2 changed files with 2 additions and 0 deletions

View File

@ -123,6 +123,7 @@ func (m *metric) AddTag(key, value string) {
if key == tag.Key { if key == tag.Key {
tag.Value = value tag.Value = value
return
} }
m.tags = append(m.tags, nil) m.tags = append(m.tags, nil)

View File

@ -63,6 +63,7 @@ func TestAddTagOverwrites(t *testing.T) {
value, ok := m.GetTag("host") value, ok := m.GetTag("host")
require.True(t, ok) require.True(t, ok)
require.Equal(t, "example.org", value) require.Equal(t, "example.org", value)
require.Equal(t, 1, len(m.TagList()))
} }
func TestRemoveTagNoEffectOnMissingTags(t *testing.T) { func TestRemoveTagNoEffectOnMissingTags(t *testing.T) {