(opts promql.EngineOpts, thanosEngineCfg ThanosEngineConfig, reg prometheus.Registerer)
| 59 | } |
| 60 | |
| 61 | func New(opts promql.EngineOpts, thanosEngineCfg ThanosEngineConfig, reg prometheus.Registerer) *Engine { |
| 62 | prometheusEngine := promql.NewEngine(opts) |
| 63 | |
| 64 | var thanosEngine *thanosengine.Engine |
| 65 | if thanosEngineCfg.Enabled { |
| 66 | thanosEngine = thanosengine.New(thanosengine.Opts{ |
| 67 | EngineOpts: opts, |
| 68 | LogicalOptimizers: thanosEngineCfg.LogicalOptimizers, |
| 69 | EnableAnalysis: true, |
| 70 | EnableXFunctions: thanosEngineCfg.EnableXFunctions, |
| 71 | DecodingConcurrency: thanosEngineCfg.DecodingConcurrency, |
| 72 | }) |
| 73 | } |
| 74 | |
| 75 | return &Engine{ |
| 76 | prometheusEngine: prometheusEngine, |
| 77 | thanosEngine: thanosEngine, |
| 78 | fallbackQueriesTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{ |
| 79 | Name: "cortex_thanos_engine_fallback_queries_total", |
| 80 | Help: "Total number of fallback queries due to not implementation in thanos engine", |
| 81 | }), |
| 82 | engineSwitchQueriesTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{ |
| 83 | Name: "cortex_engine_switch_queries_total", |
| 84 | Help: "Total number of queries where engine_type is set explicitly", |
| 85 | }, []string{"engine_type"}), |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | func (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 { |
no outgoing calls