(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, root logicalplan.Node, start time.Time, end time.Time, interval time.Duration, qs string)
| 160 | } |
| 161 | |
| 162 | func (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 | |
| 181 | prom: |
| 182 | return qf.prometheusEngine.NewRangeQuery(ctx, q, opts, qs, start, end, interval) |
| 183 | } |
| 184 | |
| 185 | func fromPromQLOpts(opts promql.QueryOpts) *thanosengine.QueryOpts { |
| 186 | if opts == nil { |
nothing calls this directly
no test coverage detected