From daf0654a40b89db9426cf9ecbd0013dea59edb7b Mon Sep 17 00:00:00 2001 From: Jon Kartago Lamida Date: Mon, 16 Dec 2024 23:06:24 +0800 Subject: [PATCH] Fix delta should not consider reset Signed-off-by: Jon Kartago Lamida --- .../operators/functions/rate_increase.go | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/streamingpromql/operators/functions/rate_increase.go b/pkg/streamingpromql/operators/functions/rate_increase.go index 2095338d6cb..7ee0cb1a278 100644 --- a/pkg/streamingpromql/operators/functions/rate_increase.go +++ b/pkg/streamingpromql/operators/functions/rate_increase.go @@ -132,14 +132,16 @@ func histogramRate(isCounter, isRate bool, hCount int, hHead []promql.HPoint, hT return nil } - err = accumulate(hHead) - if err != nil { - return nil, err + if isCounter { + err = accumulate(hHead) + if err != nil { + return nil, err - } - err = accumulate(hTail) - if err != nil { - return nil, err + } + err = accumulate(hTail) + if err != nil { + return nil, err + } } if !isCounter && (firstPoint.H.CounterResetHint != histogram.GaugeType || lastPoint.H.CounterResetHint != histogram.GaugeType) { @@ -150,11 +152,8 @@ func histogramRate(isCounter, isRate bool, hCount int, hHead []promql.HPoint, hT delta = delta.CopyToSchema(desiredSchema) } - if isCounter { - val := calculateHistogramRate(isRate, rangeStart, rangeEnd, rangeSeconds, firstPoint, lastPoint, delta, hCount) - return val, err - } - return delta, err + val := calculateHistogramRate(isRate, rangeStart, rangeEnd, rangeSeconds, firstPoint, lastPoint, delta, hCount) + return val, err } func floatRate(isCounter, isRate bool, fCount int, fHead []promql.FPoint, fTail []promql.FPoint, rangeStart int64, rangeEnd int64, rangeSeconds float64) float64 {