Skip to content

Commit

Permalink
engine: make it possible to write lookback delta and stats (#502)
Browse files Browse the repository at this point in the history
LookbackDelta and Stats were unexported fields of the struct.
We cannot write to them like this so we need to export them.

Signed-off-by: Michael Hoffmann <[email protected]>
Co-authored-by: Michael Hoffmann <[email protected]>
  • Loading branch information
MichaHoffmann and Michael Hoffmann authored Dec 17, 2024
1 parent 40b4c4c commit 9dbff30
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ func (o Opts) getLogicalOptimizers() []logicalplan.Optimizer {

// QueryOpts implements promql.QueryOpts but allows to override more engine default options.
type QueryOpts struct {
lookbackDelta time.Duration

enablePerStepStats bool
// These values are used to implement promql.QueryOpts, they have weird "Param" suffix because
// they are accessed by methods of the same name.
LookbackDeltaParam time.Duration
EnablePerStepStatsParam bool

// DecodingConcurrency can be used to override the DecodingConcurrency engine setting.
DecodingConcurrency int
Expand All @@ -112,16 +113,16 @@ type QueryOpts struct {
EnablePartialResponses bool
}

func (opts QueryOpts) LookbackDelta() time.Duration { return opts.lookbackDelta }
func (opts QueryOpts) EnablePerStepStats() bool { return opts.enablePerStepStats }
func (opts QueryOpts) LookbackDelta() time.Duration { return opts.LookbackDeltaParam }
func (opts QueryOpts) EnablePerStepStats() bool { return opts.EnablePerStepStatsParam }

func fromPromQLOpts(opts promql.QueryOpts) *QueryOpts {
if opts == nil {
return &QueryOpts{}
}
return &QueryOpts{
lookbackDelta: opts.LookbackDelta(),
enablePerStepStats: opts.EnablePerStepStats(),
LookbackDeltaParam: opts.LookbackDelta(),
EnablePerStepStatsParam: opts.EnablePerStepStats(),
}
}

Expand Down

0 comments on commit 9dbff30

Please sign in to comment.