diff --git a/promql/engine.go b/promql/engine.go index a6fc29540..fd2022207 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -2360,15 +2360,14 @@ func (ev *evaluator) aggregation(op parser.ItemType, grouping []string, without } } - lb := labels.NewBuilder(labels.EmptyLabels()) var buf []byte for si, s := range vec { metric := s.Metric if op == parser.COUNT_VALUES { - lb.Reset(metric) - lb.Set(valueLabel, strconv.FormatFloat(s.V, 'f', -1, 64)) - metric = lb.Labels(labels.EmptyLabels()) + enh.resetBuilder(metric) + enh.lb.Set(valueLabel, strconv.FormatFloat(s.V, 'f', -1, 64)) + metric = enh.lb.Labels(labels.EmptyLabels()) // We've changed the metric so we have to recompute the grouping key. recomputeGroupingKey = true @@ -2385,14 +2384,14 @@ func (ev *evaluator) aggregation(op parser.ItemType, grouping []string, without group, ok := result[groupingKey] // Add a new group if it doesn't exist. if !ok { - lb.Reset(metric) + enh.resetBuilder(metric) if without { - lb.Del(grouping...) - lb.Del(labels.MetricName) + enh.lb.Del(grouping...) + enh.lb.Del(labels.MetricName) } else { - lb.Keep(grouping...) + enh.lb.Keep(grouping...) } - m := lb.Labels(labels.EmptyLabels()) + m := enh.lb.Labels(labels.EmptyLabels()) newAgg := &groupedAggregation{ labels: m, value: s.V,