MCPcopy Index your code
hub / github.com/cortexproject/cortex / FindMinMaxTime

Function FindMinMaxTime

pkg/util/time.go:126–152  ·  view source on GitHub ↗

FindMinMaxTime returns the time in milliseconds of the earliest and latest point in time the statement will try to process. This takes into account offsets, @ modifiers, and range selectors. If the expression does not select series, then FindMinMaxTime returns (0, 0).

(r *http.Request, expr parser.Expr, lookbackDelta time.Duration, now time.Time)

Source from the content-addressed store, hash-verified

124// This takes into account offsets, @ modifiers, and range selectors.
125// If the expression does not select series, then FindMinMaxTime returns (0, 0).
126func FindMinMaxTime(r *http.Request, expr parser.Expr, lookbackDelta time.Duration, now time.Time) (int64, int64) {
127 isQuery := strings.HasSuffix(r.URL.Path, "/query")
128
129 var startTime, endTime int64
130 if isQuery {
131 if t, err := ParseTimeParam(r, "time", now.UnixMilli()); err == nil {
132 startTime = t
133 endTime = t
134 }
135 } else {
136 if st, err := ParseTime(r.FormValue("start")); err == nil {
137 if et, err := ParseTime(r.FormValue("end")); err == nil {
138 startTime = st
139 endTime = et
140 }
141 }
142 }
143
144 es := &parser.EvalStmt{
145 Expr: expr,
146 Start: TimeFromMillis(startTime),
147 End: TimeFromMillis(endTime),
148 LookbackDelta: lookbackDelta,
149 }
150
151 return promql.FindMinMaxTime(es)
152}
153
154// SlotInfoFunc returns the slot number and the total number of slots
155type SlotInfoFunc func() (int, int)

Callers 2

rejectQueryOrSetPriorityFunction · 0.92
TestFindMinMaxTimeFunction · 0.85

Calls 3

ParseTimeParamFunction · 0.85
ParseTimeFunction · 0.85
TimeFromMillisFunction · 0.85

Tested by 1

TestFindMinMaxTimeFunction · 0.68