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

Method NewInstantQuery

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

Source from the content-addressed store, hash-verified

87}
88
89func (qf *Engine) NewInstantQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, ts time.Time) (promql.Query, error) {
90 if engineType := GetEngineType(ctx); engineType == Prometheus {
91 qf.engineSwitchQueriesTotal.WithLabelValues(string(Prometheus)).Inc()
92 goto prom
93 } else if engineType == Thanos {
94 qf.engineSwitchQueriesTotal.WithLabelValues(string(Thanos)).Inc()
95 }
96
97 if qf.thanosEngine != nil {
98 res, err := qf.thanosEngine.MakeInstantQuery(ctx, q, fromPromQLOpts(opts), qs, ts)
99 if err != nil {
100 if thanosengine.IsUnimplemented(err) {
101 // fallback to use prometheus engine
102 qf.fallbackQueriesTotal.Inc()
103 goto prom
104 }
105 return nil, err
106 }
107 return res, nil
108 }
109
110prom:
111 return qf.prometheusEngine.NewInstantQuery(ctx, q, opts, qs, ts)
112}
113
114func (qf *Engine) NewRangeQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, start, end time.Time, interval time.Duration) (promql.Query, error) {
115 if engineType := GetEngineType(ctx); engineType == Prometheus {

Callers 6

TestEngine_FallbackFunction · 0.80
TestEngine_SwitchFunction · 0.80
TestEngine_XFunctionsFunction · 0.80
InstantQueryHandlerMethod · 0.80
executeQueryFunction · 0.80

Calls 3

GetEngineTypeFunction · 0.85
fromPromQLOptsFunction · 0.85
IncMethod · 0.45

Tested by 3

TestEngine_FallbackFunction · 0.64
TestEngine_SwitchFunction · 0.64
TestEngine_XFunctionsFunction · 0.64