mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-03 13:42:14 -04:00
promql: Check 1st histogram's CRH in sum_over_time
avg_over_time already correctly checked the counter reset hint fo all histograms, but in sum_over_time, the 1st histogram was missed. In both cases, the 1st histogram is processed outside the loop. Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
ff49406cba
commit
e80a3e1b21
1 changed files with 11 additions and 6 deletions
|
|
@ -1092,6 +1092,15 @@ func funcSumOverTime(_ []Vector, matrixVal Matrix, args parser.Expressions, enh
|
|||
vec, err := aggrHistOverTime(matrixVal, enh, func(s Series) (*histogram.FloatHistogram, error) {
|
||||
var counterResetSeen, notCounterResetSeen bool
|
||||
|
||||
trackCounterReset := func(h *histogram.FloatHistogram) {
|
||||
switch h.CounterResetHint {
|
||||
case histogram.CounterReset:
|
||||
counterResetSeen = true
|
||||
case histogram.NotCounterReset:
|
||||
notCounterResetSeen = true
|
||||
}
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if counterResetSeen && notCounterResetSeen {
|
||||
annos.Add(annotations.NewHistogramCounterResetCollisionWarning(args[0].PositionRange(), annotations.HistogramAgg))
|
||||
|
|
@ -1099,13 +1108,9 @@ func funcSumOverTime(_ []Vector, matrixVal Matrix, args parser.Expressions, enh
|
|||
}()
|
||||
|
||||
sum := s.Histograms[0].H.Copy()
|
||||
trackCounterReset(sum)
|
||||
for _, h := range s.Histograms[1:] {
|
||||
switch h.H.CounterResetHint {
|
||||
case histogram.CounterReset:
|
||||
counterResetSeen = true
|
||||
case histogram.NotCounterReset:
|
||||
notCounterResetSeen = true
|
||||
}
|
||||
trackCounterReset(h.H)
|
||||
_, _, err := sum.Add(h.H)
|
||||
if err != nil {
|
||||
return sum, err
|
||||
|
|
|
|||
Loading…
Reference in a new issue