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

Method MakeInstantQueryFromPlan

pkg/engine/engine.go:138–160  ·  view source on GitHub ↗
(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, root logicalplan.Node, ts time.Time, qs string)

Source from the content-addressed store, hash-verified

136}
137
138func (qf *Engine) MakeInstantQueryFromPlan(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, root logicalplan.Node, ts time.Time, qs string) (promql.Query, error) {
139 if engineType := GetEngineType(ctx); engineType == Prometheus {
140 qf.engineSwitchQueriesTotal.WithLabelValues(string(Prometheus)).Inc()
141 } else if engineType == Thanos {
142 qf.engineSwitchQueriesTotal.WithLabelValues(string(Thanos)).Inc()
143 }
144
145 if qf.thanosEngine != nil {
146 res, err := qf.thanosEngine.MakeInstantQueryFromPlan(ctx, q, fromPromQLOpts(opts), root, ts)
147 if err != nil {
148 if thanosengine.IsUnimplemented(err) {
149 // fallback to use prometheus engine
150 qf.fallbackQueriesTotal.Inc()
151 goto prom
152 }
153 return nil, err
154 }
155 return res, nil
156 }
157
158prom:
159 return qf.prometheusEngine.NewInstantQuery(ctx, q, opts, qs, ts)
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 {

Callers

nothing calls this directly

Calls 5

GetEngineTypeFunction · 0.85
fromPromQLOptsFunction · 0.85
NewInstantQueryMethod · 0.80
IncMethod · 0.45

Tested by

no test coverage detected