mirror of
https://github.com/prometheus/prometheus.git
synced 2025-09-21 13:51:00 +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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pathLoop:
|
||||||
for i := len(path) - 1; i >= 0; i-- { // Walk backwards up the path.
|
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)
|
call, ok := path[i].(*parser.Call)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue pathLoop
|
||||||
}
|
}
|
||||||
switch call.Func.Name {
|
switch call.Func.Name {
|
||||||
case "histogram_count", "histogram_sum", "histogram_avg":
|
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
|
n.SkipHistogramBuckets = true
|
||||||
case "histogram_quantile", "histogram_fraction":
|
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
|
n.SkipHistogramBuckets = false
|
||||||
default:
|
break pathLoop
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
return errors.New("stop")
|
return errors.New("stop")
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user