Documentation
¶
Index ¶
- type BuiltinStats
- type QuerySamples
- func (qs *QuerySamples) IncrementSamplesAtStep(i int, samples int64)
- func (qs *QuerySamples) IncrementSamplesAtTimestamp(t, samples int64)
- func (qs *QuerySamples) IncrementSamplesReadAtStep(i int, n int64)
- func (qs *QuerySamples) IncrementSamplesReadAtTimestamp(t, n int64)
- func (qs *QuerySamples) InitStepTracking(start, end, interval int64)
- func (qs *QuerySamples) MergeSamplesReadFromSubquery(child *QuerySamples, parentStart, parentInterval int64, parentNumSteps int, ...)
- func (*QuerySamples) NewChild() *QuerySamples
- func (qs *QuerySamples) SamplesReadPerStepMap() *TotalSamplesPerStep
- func (qs *QuerySamples) StepTrackingEnabled() bool
- func (qs *QuerySamples) TotalSamplesPerStepMap() *TotalSamplesPerStep
- func (qs *QuerySamples) UpdatePeak(samples int)
- func (qs *QuerySamples) UpdatePeakFromSubquery(other *QuerySamples)
- type QueryStats
- type QueryTimers
- type QueryTiming
- type SpanTimer
- type Statistics
- type Stats
- type Timer
- type TimerGroup
- type TotalSamplesPerStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuiltinStats ¶
type BuiltinStats struct {
Timings queryTimings `json:"timings,omitempty"`
Samples *querySamples `json:"samples,omitempty"`
}
BuiltinStats holds the statistics that Prometheus's core gathers.
func (*BuiltinStats) Builtin ¶
func (s *BuiltinStats) Builtin() BuiltinStats
type QuerySamples ¶
type QuerySamples struct {
// PeakSamples represent the highest count of samples considered
// while evaluating a query. It corresponds to the peak value of
// currentSamples, which is in turn compared against the MaxSamples
// configured in the engine.
PeakSamples int
// TotalSamples represents the total number of samples loaded while
// evaluating a query. For range-vector functions, each step counts the
// full window (points may be counted in multiple steps).
TotalSamples int64
// TotalSamplesPerStep represents the total number of samples scanned
// per step while evaluating a query. Each step should be identical to the
// TotalSamples when a step is run as an instant query, which means
// we intentionally do not account for optimizations that happen inside the
// range query engine that reduce the actual work that happens.
// For range-vector functions, each step counts the full window at that step.
TotalSamplesPerStep []int64
// SamplesRead is the number of samples read (I/O). For range-vector functions
// in range queries, only new points per step are counted; elsewhere it
// equals TotalSamples.
SamplesRead int64
// SamplesReadPerStep is the number of samples read per step. For
// range-vector functions, step 0 counts the full window and later
// steps count only the points not already covered by the previous
// step's window.
SamplesReadPerStep []int64
EnablePerStepStats bool
StartTimestamp int64
Interval int64
}
func NewChildWithStepTracking ¶ added in v0.313.0
func NewChildWithStepTracking(start, end, interval int64) *QuerySamples
NewChildWithStepTracking creates a child QuerySamples with per-step tracking enabled and initializes its per-step arrays via InitStepTracking.
func NewQuerySamples ¶
func NewQuerySamples(enablePerStepStats bool) *QuerySamples
func (*QuerySamples) IncrementSamplesAtStep ¶
func (qs *QuerySamples) IncrementSamplesAtStep(i int, samples int64)
IncrementSamplesAtStep increments the total samples count. Use this if you know the step index.
func (*QuerySamples) IncrementSamplesAtTimestamp ¶
func (qs *QuerySamples) IncrementSamplesAtTimestamp(t, samples int64)
IncrementSamplesAtTimestamp increments the total samples count. Use this if you only have the corresponding step timestamp.
func (*QuerySamples) IncrementSamplesReadAtStep ¶ added in v0.313.0
func (qs *QuerySamples) IncrementSamplesReadAtStep(i int, n int64)
IncrementSamplesReadAtStep increments the samples-read count. Use this when you know the step index.
func (*QuerySamples) IncrementSamplesReadAtTimestamp ¶ added in v0.313.0
func (qs *QuerySamples) IncrementSamplesReadAtTimestamp(t, n int64)
IncrementSamplesReadAtTimestamp increments the samples-read count. Use this when you only have the step timestamp.
func (*QuerySamples) InitStepTracking ¶
func (qs *QuerySamples) InitStepTracking(start, end, interval int64)
func (*QuerySamples) MergeSamplesReadFromSubquery ¶ added in v0.313.0
func (qs *QuerySamples) MergeSamplesReadFromSubquery(child *QuerySamples, parentStart, parentInterval int64, parentNumSteps int, outerOffset, outerRange int64)
MergeSamplesReadFromSubquery merges only SamplesRead and SamplesReadPerStep from the child (subquery) into the parent. TotalSamples and TotalSamplesPerStep are not merged, because the outer range-eval loop already counts those when it iterates over the pre-computed matrix. The child must have per-step tracking enabled (callers should construct it via NewChildWithStepTracking).
parentStart, parentInterval and parentNumSteps describe the parent's step grid; they are passed explicitly so that gap filtering still works when the parent has per-step tracking disabled. parentNumSteps <= 1 (instant query) disables step attribution and gap filtering: the child's total is folded into qs.SamplesRead (and qs.SamplesReadPerStep[0] when allocated).
The child timestamp tk is shifted forward by outerOffset before being matched against the parent's step grid, so that an offset subquery (whose iterations run earlier than the parent step) is attributed to the parent step that actually consumes its output. Each child step is attributed to the earliest parent step whose timestamp is >= tk+outerOffset; samples before the first parent step are attributed to step 0 and samples after the last clamp to the last step.
outerRange is the consumed window width at each parent step (i.e. selRange of the outer call when the subquery is used as a function's matrix argument). When outerRange > 0, child steps whose shifted timestamp falls in a gap between consecutive parent windows (i.e. tk+outerOffset <= parentTs-outerRange) are skipped, so the count reflects only samples that actually contribute to the output. Pass 0 for both outerOffset and outerRange to disable shifting and gap filtering (e.g. for a bare *parser.SubqueryExpr where every child step is part of the parent matrix output).
func (*QuerySamples) NewChild ¶
func (*QuerySamples) NewChild() *QuerySamples
func (*QuerySamples) SamplesReadPerStepMap ¶ added in v0.313.0
func (qs *QuerySamples) SamplesReadPerStepMap() *TotalSamplesPerStep
SamplesReadPerStepMap returns the per-step samples read as a map (timestamp -> count), or nil if per-step stats are disabled.
func (*QuerySamples) StepTrackingEnabled ¶ added in v0.313.0
func (qs *QuerySamples) StepTrackingEnabled() bool
func (*QuerySamples) TotalSamplesPerStepMap ¶
func (qs *QuerySamples) TotalSamplesPerStepMap() *TotalSamplesPerStep
func (*QuerySamples) UpdatePeak ¶
func (qs *QuerySamples) UpdatePeak(samples int)
UpdatePeak updates the peak number of samples considered in the evaluation of a query as used with the MaxSamples limit.
func (*QuerySamples) UpdatePeakFromSubquery ¶
func (qs *QuerySamples) UpdatePeakFromSubquery(other *QuerySamples)
UpdatePeakFromSubquery updates the peak number of samples considered in a query from its evaluation of a subquery.
type QueryStats ¶
type QueryStats interface {
Builtin() BuiltinStats
}
QueryStats holds BuiltinStats and any other stats the particular implementation wants to collect.
func NewQueryStats ¶
func NewQueryStats(s *Statistics) QueryStats
NewQueryStats makes a QueryStats struct with all QueryTimings found in the given TimerGroup.
type QueryTimers ¶
type QueryTimers struct {
*TimerGroup
}
func NewQueryTimers ¶
func NewQueryTimers() *QueryTimers
func (*QueryTimers) GetSpanTimer ¶
func (qs *QueryTimers) GetSpanTimer(ctx context.Context, qt QueryTiming, observers ...prometheus.Observer) (*SpanTimer, context.Context)
type QueryTiming ¶
type QueryTiming int
QueryTiming identifies the code area or functionality in which time is spent during a query.
const ( EvalTotalTime QueryTiming = iota ResultSortTime QueryPreparationTime InnerEvalTime ExecQueueTime ExecTotalTime )
Query timings.
func (QueryTiming) SpanOperation ¶
func (s QueryTiming) SpanOperation() string
SpanOperation returns a string representation of a QueryTiming span operation.
func (QueryTiming) String ¶
func (s QueryTiming) String() string
Return a string representation of a QueryTiming identifier.
type SpanTimer ¶
type SpanTimer struct {
// contains filtered or unexported fields
}
SpanTimer unifies tracing and timing, to reduce repetition.
func NewSpanTimer ¶
type Statistics ¶
type Statistics struct {
Timers *QueryTimers
Samples *QuerySamples
}
type Stats ¶
type Stats struct {
TimerStats *QueryTimers
SampleStats *QuerySamples
}
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
A Timer that can be started and stopped and accumulates the total time it was running (the time between Start() and Stop()).
func (*Timer) ElapsedTime ¶
ElapsedTime returns the time that passed since starting the timer.
type TimerGroup ¶
type TimerGroup struct {
// contains filtered or unexported fields
}
A TimerGroup represents a group of timers relevant to a single query.
func (*TimerGroup) GetTimer ¶
func (t *TimerGroup) GetTimer(name fmt.Stringer) *Timer
GetTimer gets (and creates, if necessary) the Timer for a given code section.
func (*TimerGroup) String ¶
func (t *TimerGroup) String() string
Return a string representation of a TimerGroup.