mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
38 lines
732 B
Go
38 lines
732 B
Go
|
package promql
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"github.com/prometheus/prometheus/promql/parser"
|
||
|
"github.com/prometheus/prometheus/promql/parser/posrange"
|
||
|
)
|
||
|
|
||
|
func findPathRange(path []parser.Node, eRanges []evalRange) time.Duration {
|
||
|
var (
|
||
|
evalRange time.Duration
|
||
|
depth int
|
||
|
)
|
||
|
for _, r := range eRanges {
|
||
|
// Check if we are a child
|
||
|
child := true
|
||
|
for i, p := range r.Prefix {
|
||
|
if p != path[i].PositionRange() {
|
||
|
child = false
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
if child && len(r.Prefix) > depth {
|
||
|
evalRange = r.Range
|
||
|
depth = len(r.Prefix)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return evalRange
|
||
|
}
|
||
|
|
||
|
// evalRange summarizes a defined evalRange (from a MatrixSelector) within the asg
|
||
|
type evalRange struct {
|
||
|
Prefix []posrange.PositionRange
|
||
|
Range time.Duration
|
||
|
}
|