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

Method MakeRangeQueryFromPlan

pkg/engine/engine.go:162–183  ·  view source on GitHub ↗
(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, root logicalplan.Node, start time.Time, end time.Time, interval time.Duration, qs string)

Source from the content-addressed store, hash-verified

160}
161
162func (qf *Engine) MakeRangeQueryFromPlan(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, root logicalplan.Node, start time.Time, end time.Time, interval time.Duration, qs string) (promql.Query, error) {
163 if engineType := GetEngineType(ctx); engineType == Prometheus {
164 qf.engineSwitchQueriesTotal.WithLabelValues(string(Prometheus)).Inc()
165 } else if engineType == Thanos {
166 qf.engineSwitchQueriesTotal.WithLabelValues(string(Thanos)).Inc()
167 }
168 if qf.thanosEngine != nil {
169 res, err := qf.thanosEngine.MakeRangeQueryFromPlan(ctx, q, fromPromQLOpts(opts), root, start, end, interval)
170 if err != nil {
171 if thanosengine.IsUnimplemented(err) {
172 // fallback to use prometheus engine
173 qf.fallbackQueriesTotal.Inc()
174 goto prom
175 }
176 return nil, err
177 }
178 return res, nil
179 }
180
181prom:
182 return qf.prometheusEngine.NewRangeQuery(ctx, q, opts, qs, start, end, interval)
183}
184
185func fromPromQLOpts(opts promql.QueryOpts) *thanosengine.QueryOpts {
186 if opts == nil {

Callers

nothing calls this directly

Calls 5

GetEngineTypeFunction · 0.85
fromPromQLOptsFunction · 0.85
NewRangeQueryMethod · 0.80
IncMethod · 0.45

Tested by

no test coverage detected