Fix duplicate tags when overriding tag (#4056)
(cherry picked from commit ee9a2f73a1
)
This commit is contained in:
parent
20cc559868
commit
ba709b4748
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue