lib/storage: properly handle the case when key="__name__" is passed to MetricName.AddTag*

This commit is contained in:
Aliaksandr Valialkin 2020-10-20 19:39:57 +03:00
parent 64e2d66014
commit d12c4914f0

View File

@ -196,6 +196,10 @@ func (mn *MetricName) CopyFrom(src *MetricName) {
// AddTag adds new tag to mn with the given key and value.
func (mn *MetricName) AddTag(key, value string) {
if key == string(metricGroupTagKey) {
mn.MetricGroup = append(mn.MetricGroup, value...)
return
}
tag := mn.addNextTag()
tag.Key = append(tag.Key[:0], key...)
tag.Value = append(tag.Value[:0], value...)
@ -203,6 +207,10 @@ func (mn *MetricName) AddTag(key, value string) {
// AddTagBytes adds new tag to mn with the given key and value.
func (mn *MetricName) AddTagBytes(key, value []byte) {
if string(key) == string(metricGroupTagKey) {
mn.MetricGroup = append(mn.MetricGroup, value...)
return
}
tag := mn.addNextTag()
tag.Key = append(tag.Key[:0], key...)
tag.Value = append(tag.Value[:0], value...)