Skip to content

Commit f85b8e7

Browse files
committed
enable experimental function using parser
Signed-off-by: Sujal Gupta <[email protected]>
1 parent f53f873 commit f85b8e7

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

cmd/thanos/query.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ func registerQuery(app *extkingpin.App) {
133133

134134
enableMetricMetadataPartialResponse := cmd.Flag("metric-metadata.partial-response", "Enable partial response for metric metadata endpoint. --no-metric-metadata.partial-response for disabling.").
135135
Hidden().Default("true").Bool()
136-
137-
enableQueryExperimentalFunctions := cmd.Flag("--enable-feature=promql-experimental-functions", "Enable experimental functions for queries.")
136+
138137
activeQueryDir := cmd.Flag("query.active-query-path", "Directory to log currently active queries in the queries.active file.").Default("").String()
139138

140139
featureList := cmd.Flag("enable-feature", "Comma separated experimental feature names to enable. The current list of features is: promql-experimental-functions (enables experimental PromQL functions).").Hidden().Default("").Strings()
@@ -219,9 +218,6 @@ func registerQuery(app *extkingpin.App) {
219218
if feature == queryPushdown {
220219
level.Warn(logger).Log("msg", "This option for --enable-feature is now permanently deprecated and therefore ignored.", "option", queryPushdown)
221220
}
222-
if feature == promqlExperimentalFunctions {
223-
level.Warn(logger).Log("msg", "This option for --enable-feature is now permanently enabled and therefore a no-op.", "option", promqlExperimentalFunctions)
224-
}
225221
}
226222

227223
httpLogOpts, err := logging.ParseHTTPOptions(reqLogConfig)
@@ -322,7 +318,6 @@ func registerQuery(app *extkingpin.App) {
322318
*enableTargetPartialResponse,
323319
*enableMetricMetadataPartialResponse,
324320
*enableExemplarPartialResponse,
325-
*enableQueryExperimentalFunctions,
326321
*activeQueryDir,
327322
time.Duration(*instantDefaultMaxSourceResolution),
328323
*defaultMetadataTimeRange,

pkg/api/query/engine.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/go-kit/log"
2828
"github.com/prometheus/client_golang/prometheus"
2929
"github.com/prometheus/prometheus/promql"
30+
"github.com/prometheus/prometheus/promql/parser"
3031
"github.com/prometheus/prometheus/storage"
3132

3233
"github.com/thanos-io/promql-engine/api"
@@ -88,11 +89,14 @@ func NewQueryFactory(
8889
lookbackDelta time.Duration,
8990
evaluationInterval time.Duration,
9091
enableXFunctions bool,
91-
enableQueryExperimentalFunctions bool,
92+
enablePromQLExperimentalFunctions bool,
9293
activeQueryTracker *promql.ActiveQueryTracker,
9394
mode PromqlQueryMode,
9495
) *QueryFactory {
9596
makeOpts := func(registry prometheus.Registerer) engine.Opts {
97+
// Set global experimental functions flag
98+
parser.EnableExperimentalFunctions = enablePromQLExperimentalFunctions
99+
96100
opts := engine.Opts{
97101
EngineOpts: promql.EngineOpts{
98102
Logger: logutil.GoKitLogToSlog(logger),
@@ -107,9 +111,8 @@ func NewQueryFactory(
107111
EnableNegativeOffset: true,
108112
EnableAtModifier: true,
109113
},
110-
EnableXFunctions: enableXFunctions,
111-
EnableQueryExperimentalFunctions: enableQueryExperimentalFunctions,
112-
EnableAnalysis: true,
114+
EnableXFunctions: enableXFunctions,
115+
EnableAnalysis: true,
113116
}
114117
if activeQueryTracker != nil {
115118
opts.ActiveQueryTracker = activeQueryTracker

0 commit comments

Comments
 (0)