mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Extract interface from ActivityQueryTracker and allows passing custom implementation (#102)
* Extract QueryTracker interface. * Update from Prometheus PR 10071. * Update promql/engine.go Co-authored-by: Mauro Stettler <mauro.stettler@gmail.com> * Update promql/engine.go Co-authored-by: Mauro Stettler <mauro.stettler@gmail.com> Co-authored-by: Mauro Stettler <mauro.stettler@gmail.com>
This commit is contained in:
parent
5205ff1a81
commit
3117005b22
|
@ -207,13 +207,29 @@ func contextErr(err error, env string) error {
|
|||
}
|
||||
}
|
||||
|
||||
// QueryTracker provides access to two features:
|
||||
// 1) tracking of active queries that are logged on restart if PromQL engine crashes while executing the query, and
|
||||
// 2) enforcement of the maximum number of concurrent requests.
|
||||
type QueryTracker interface {
|
||||
// GetMaxConcurrent returns maximum number of concurrent queries that are allowed by this tracker.
|
||||
GetMaxConcurrent() int
|
||||
|
||||
// Insert inserts query into query tracker. This call must block if maximum number of queries is already running.
|
||||
// If Insert doesn't return error then returned integer value should be used in subsequent Delete call.
|
||||
// Insert should return error if context is finished before query can proceed, and integer value returned in this case should be ignored by caller.
|
||||
Insert(ctx context.Context, query string) (int, error)
|
||||
|
||||
// Delete removes query from activity tracker. InsertIndex is value returned by Insert call.
|
||||
Delete(insertIndex int)
|
||||
}
|
||||
|
||||
// EngineOpts contains configuration options used when creating a new Engine.
|
||||
type EngineOpts struct {
|
||||
Logger log.Logger
|
||||
Reg prometheus.Registerer
|
||||
MaxSamples int
|
||||
Timeout time.Duration
|
||||
ActiveQueryTracker *ActiveQueryTracker
|
||||
ActiveQueryTracker QueryTracker
|
||||
// LookbackDelta determines the time since the last sample after which a time
|
||||
// series is considered stale.
|
||||
LookbackDelta time.Duration
|
||||
|
@ -236,7 +252,7 @@ type Engine struct {
|
|||
metrics *engineMetrics
|
||||
timeout time.Duration
|
||||
maxSamplesPerQuery int
|
||||
activeQueryTracker *ActiveQueryTracker
|
||||
activeQueryTracker QueryTracker
|
||||
queryLogger QueryLogger
|
||||
queryLoggerLock sync.RWMutex
|
||||
lookbackDelta time.Duration
|
||||
|
|
Loading…
Reference in a new issue