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

Function executeQuery

pkg/ruler/compat.go:196–220  ·  view source on GitHub ↗
(ctx context.Context, engine promql.QueryEngine, q storage.Queryable, qs string, t time.Time)

Source from the content-addressed store, hash-verified

194}
195
196func executeQuery(ctx context.Context, engine promql.QueryEngine, q storage.Queryable, qs string, t time.Time) (promql.Vector, error) {
197 qry, err := engine.NewInstantQuery(ctx, q, nil, qs, t)
198 if err != nil {
199 return nil, err
200 }
201 defer qry.Close()
202
203 res := qry.Exec(ctx)
204 if res.Err != nil {
205 return nil, res.Err
206 }
207
208 switch v := res.Value.(type) {
209 case promql.Vector:
210 return v, nil
211 case promql.Scalar:
212 return promql.Vector{promql.Sample{
213 T: v.T,
214 F: v.V,
215 Metric: labels.Labels{},
216 }}, nil
217 default:
218 return nil, errors.New("rule result is not a vector or scalar")
219 }
220}
221
222func wrapWithMiddleware(next QueryExecutor, overrides RulesLimits, userID string, lookbackDelta time.Duration) rules.QueryFunc {
223 return func(ctx context.Context, qs string, t time.Time) (promql.Vector, error) {

Callers 1

engineQueryFuncFunction · 0.85

Calls 3

NewInstantQueryMethod · 0.80
CloseMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected