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

Function New

pkg/engine/engine.go:61–87  ·  view source on GitHub ↗
(opts promql.EngineOpts, thanosEngineCfg ThanosEngineConfig, reg prometheus.Registerer)

Source from the content-addressed store, hash-verified

59}
60
61func 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
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 {

Callers 6

initRulerMethod · 0.92
NewFunction · 0.92
TestEngine_FallbackFunction · 0.70
TestEngine_SwitchFunction · 0.70
TestEngine_XFunctionsFunction · 0.70

Calls

no outgoing calls

Tested by 4

TestEngine_FallbackFunction · 0.56
TestEngine_SwitchFunction · 0.56
TestEngine_XFunctionsFunction · 0.56