fix build for stringlabels tag

Signed-off-by: Nicolás Pazos <npazosmendez@gmail.com>
This commit is contained in:
Nicolás Pazos 2023-11-09 11:22:53 -03:00
parent fbdbf2ccbd
commit 04fe4bfb20

View file

@ -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.