diff --git a/lib/promrelabel/relabel.go b/lib/promrelabel/relabel.go index be3c5f6fa..d48dde26a 100644 --- a/lib/promrelabel/relabel.go +++ b/lib/promrelabel/relabel.go @@ -592,9 +592,7 @@ func GetLabelByName(labels []prompbmarshal.Label, name string) *prompbmarshal.La // This should help GC cleaning up label.Name and label.Value strings. func CleanLabels(labels []prompbmarshal.Label) { for i := range labels { - label := &labels[i] - label.Name = "" - label.Value = "" + labels[i] = prompbmarshal.Label{} } } diff --git a/lib/promscrape/scrapework.go b/lib/promscrape/scrapework.go index a5fa45aa5..a516354f3 100644 --- a/lib/promscrape/scrapework.go +++ b/lib/promscrape/scrapework.go @@ -736,11 +736,9 @@ func (wc *writeRequestCtx) resetNoRows() { labels := wc.labels for i := range labels { - label := &labels[i] - label.Name = "" - label.Value = "" + labels[i] = prompbmarshal.Label{} } - wc.labels = wc.labels[:0] + wc.labels = labels[:0] wc.samples = wc.samples[:0] } diff --git a/lib/promutils/labels.go b/lib/promutils/labels.go index b4f9216eb..75c223539 100644 --- a/lib/promutils/labels.go +++ b/lib/promutils/labels.go @@ -282,9 +282,7 @@ func (x *Labels) RemoveLabelsWithDoubleUnderscorePrefix() { func cleanLabels(labels []prompbmarshal.Label) { for i := range labels { - label := &labels[i] - label.Name = "" - label.Value = "" + labels[i] = prompbmarshal.Label{} } } diff --git a/lib/protoparser/opentelemetry/stream/streamparser.go b/lib/protoparser/opentelemetry/stream/streamparser.go index be5f21e4d..9d4dab2cc 100644 --- a/lib/protoparser/opentelemetry/stream/streamparser.go +++ b/lib/protoparser/opentelemetry/stream/streamparser.go @@ -252,9 +252,7 @@ func (wr *writeContext) reset() { func resetLabels(labels []prompbmarshal.Label) []prompbmarshal.Label { for i := range labels { - label := &labels[i] - label.Name = "" - label.Value = "" + labels[i] = prompbmarshal.Label{} } return labels[:0] }