Skip to content

Commit 0c8ef5f

Browse files
authored
add option to enable holt winters (#179)
Signed-off-by: yeya24 <benye@amazon.com>
1 parent 60fd1dc commit 0c8ef5f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

opts.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func init() {
7676
}
7777

7878
for _, f := range parser.Functions {
79+
// holt_winters is excluded by default; use WithEnableHoltWinters(true) for older backends.
80+
if f.Name == "holt_winters" {
81+
continue
82+
}
7983
// Ignore experimental functions for now.
8084
if !f.Experimental {
8185
defaultSupportedFuncs = append(defaultSupportedFuncs, f)
@@ -94,6 +98,7 @@ type options struct {
9498
enableOffset bool
9599
enableAtModifier bool
96100
enableVectorMatching bool
101+
enableHoltWinters bool // holt_winters not in Prometheus 3.x; enable for older backends
97102
enableExperimentalPromQLFunctions bool
98103
atModifierMaxTimestamp int64
99104

@@ -119,6 +124,10 @@ func (o *options) applyDefaults() {
119124
o.enabledFuncs = defaultSupportedFuncs
120125
}
121126

127+
if o.enableHoltWinters && parser.Functions["holt_winters"] != nil {
128+
o.enabledFuncs = append(o.enabledFuncs, parser.Functions["holt_winters"])
129+
}
130+
122131
if o.enableExperimentalPromQLFunctions {
123132
o.enabledAggrs = append(o.enabledAggrs, experimentalPromQLAggrs...)
124133
o.enabledFuncs = append(o.enabledFuncs, experimentalSupportedFuncs...)
@@ -168,6 +177,15 @@ func WithEnableVectorMatching(enableVectorMatching bool) Option {
168177
})
169178
}
170179

180+
// WithEnableHoltWinters enables generation of holt_winters() in queries.
181+
// Disabled by default because Prometheus 3.x replaced it with double_exponential_smoothing;
182+
// enable only when fuzzing older backends that still support holt_winters.
183+
func WithEnableHoltWinters(enable bool) Option {
184+
return optionFunc(func(o *options) {
185+
o.enableHoltWinters = enable
186+
})
187+
}
188+
171189
func WithEnableExperimentalPromQLFunctions(enableExperimentalPromQLFunctions bool) Option {
172190
return optionFunc(func(o *options) {
173191
o.enableExperimentalPromQLFunctions = enableExperimentalPromQLFunctions

0 commit comments

Comments
 (0)