Merge pull request #17331 from prometheus/beorn7/promql
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run

promql: Check 1st histogram's CRH in sum_over_time
This commit is contained in:
Björn Rabenstein 2025-10-14 11:22:18 +02:00 committed by GitHub
commit a18d18e927
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 6 deletions

View file

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

View file

@ -1709,6 +1709,18 @@ eval instant at 14m histogram_count(avg_over_time(mixed[10m]))
expect no_info
{} 9.3
# In the following two tests, the first sample has hint "not_reset"
# and the second has "reset". This tests if the conflict is detected
# between the first two samples, too.
eval instant at 11m histogram_count(sum_over_time(mixed[2m]))
expect warn msg:PromQL warning: conflicting counter resets during histogram aggregation
expect no_info
{} 21
eval instant at 11m histogram_count(avg_over_time(mixed[2m]))
expect warn msg:PromQL warning: conflicting counter resets during histogram aggregation
expect no_info
{} 10.5
# Test histogram_quantile annotations.
load 1m