| 112 | } |
| 113 | |
| 114 | func (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 { |
| 116 | qf.engineSwitchQueriesTotal.WithLabelValues(string(Prometheus)).Inc() |
| 117 | goto prom |
| 118 | } else if engineType == Thanos { |
| 119 | qf.engineSwitchQueriesTotal.WithLabelValues(string(Thanos)).Inc() |
| 120 | } |
| 121 | if qf.thanosEngine != nil { |
| 122 | res, err := qf.thanosEngine.MakeRangeQuery(ctx, q, fromPromQLOpts(opts), qs, start, end, interval) |
| 123 | if err != nil { |
| 124 | if thanosengine.IsUnimplemented(err) { |
| 125 | // fallback to use prometheus engine |
| 126 | qf.fallbackQueriesTotal.Inc() |
| 127 | goto prom |
| 128 | } |
| 129 | return nil, err |
| 130 | } |
| 131 | return res, nil |
| 132 | } |
| 133 | |
| 134 | prom: |
| 135 | return qf.prometheusEngine.NewRangeQuery(ctx, q, opts, qs, start, end, interval) |
| 136 | } |
| 137 | |
| 138 | func (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 { |