From 04fe4bfb208e78c513b130331314f6653ab1651c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Pazos?= Date: Thu, 9 Nov 2023 11:22:53 -0300 Subject: [PATCH] fix build for stringlabels tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolás Pazos --- storage/remote/codec.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/storage/remote/codec.go b/storage/remote/codec.go index e18901900..4ab881bf0 100644 --- a/storage/remote/codec.go +++ b/storage/remote/codec.go @@ -819,11 +819,6 @@ func labelsToLabelRefsProto(lbls labels.Labels, pool *lookupPool, buf []prompb.L func labelsToUint32Slice(lbls labels.Labels, symbolTable *rwSymbolTable, buf []uint32) []uint32 { result := buf[:0] - // ensure slice capacity - if cap(result)-len(result) < len(lbls)*2 { - result = append(make([]uint32, 0, len(lbls)*2), result...) - } - lbls.Range(func(l labels.Label) { result = append(result, symbolTable.Ref(l.Name)) result = append(result, symbolTable.Ref(l.Value)) @@ -832,7 +827,7 @@ func labelsToUint32Slice(lbls labels.Labels, symbolTable *rwSymbolTable, buf []u } func Uint32RefToLabels(symbols string, minLabels []uint32) labels.Labels { - ls := make(labels.Labels, 0, len(minLabels)/2) + ls := labels.NewScratchBuilder(len(minLabels) / 2) labelIdx := 0 for labelIdx < len(minLabels) { @@ -844,11 +839,11 @@ func Uint32RefToLabels(symbols string, minLabels []uint32) labels.Labels { offset, length = unpackRef(minLabels[labelIdx+1]) value := symbols[offset : offset+length] - ls = append(ls, labels.Label{Name: name, Value: value}) + ls.Add(name, value) labelIdx += 2 } - return ls + return ls.Labels() } // metricTypeToMetricTypeProto transforms a Prometheus metricType into prompb metricType. Since the former is a string we need to transform it to an enum.