diff --git a/lib/storage/metric_name.go b/lib/storage/metric_name.go index 95b0ee2faa..09c3dfcf67 100644 --- a/lib/storage/metric_name.go +++ b/lib/storage/metric_name.go @@ -375,7 +375,11 @@ func (mn *MetricName) Marshal(dst []byte) []byte { dst = marshalTagValue(dst, mn.MetricGroup) // Marshal tags. - dst = marshalTags(dst, mn.Tags) + tags := mn.Tags + for i := range tags { + t := &tags[i] + dst = t.Marshal(dst) + } return dst } @@ -635,20 +639,6 @@ func (ts *canonicalTagsSort) Swap(i, j int) { x[i], x[j] = x[j], x[i] } -func marshalTags(dst []byte, tags []Tag) []byte { - var prevKey []byte - for i := range tags { - t := &tags[i] - if string(prevKey) == string(t.Key) { - // Skip duplicate keys, since they aren't allowed in Prometheus data model. - continue - } - prevKey = t.Key - dst = t.Marshal(dst) - } - return dst -} - func copyTags(dst, src []Tag) []Tag { dstLen := len(dst) if n := dstLen + len(src) - cap(dst); n > 0 {