mirror of
https://github.com/prometheus/prometheus.git
synced 2025-09-20 21:31:02 +02:00
promql: Fix HistogramStatsIterator usage for subqueries
Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
4e94ee0109
commit
0746f388b0
@ -3891,20 +3891,34 @@ func detectHistogramStatsDecoding(expr parser.Expr) {
|
||||
return nil
|
||||
}
|
||||
|
||||
pathLoop:
|
||||
for i := len(path) - 1; i >= 0; i-- { // Walk backwards up the path.
|
||||
if _, ok := path[i].(*parser.SubqueryExpr); ok {
|
||||
// If we ever see a subquery in the path, we
|
||||
// will not skip the buckets. We need the
|
||||
// buckets for correct counter reset detection.
|
||||
n.SkipHistogramBuckets = false
|
||||
break pathLoop
|
||||
}
|
||||
call, ok := path[i].(*parser.Call)
|
||||
if !ok {
|
||||
continue
|
||||
continue pathLoop
|
||||
}
|
||||
switch call.Func.Name {
|
||||
case "histogram_count", "histogram_sum", "histogram_avg":
|
||||
// We allow skipping buckets preliminarily. But
|
||||
// we will continue through the path to see if
|
||||
// we find a subquery (or a histogram function)
|
||||
// further up (the latter wouldn't make sense,
|
||||
// but no harm in detecting it).
|
||||
n.SkipHistogramBuckets = true
|
||||
case "histogram_quantile", "histogram_fraction":
|
||||
// If we ever see a function that needs the
|
||||
// whole histogram, we will not skip the
|
||||
// buckets.
|
||||
n.SkipHistogramBuckets = false
|
||||
default:
|
||||
continue
|
||||
break pathLoop
|
||||
}
|
||||
break
|
||||
}
|
||||
return errors.New("stop")
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user