stats

package
v0.0.0-...-f8c6d31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

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 scanned
	// while evaluating a query.
	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.
	TotalSamplesPerStep []int64

	EnablePerStepStats bool
	// contains filtered or unexported fields
}

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) InitStepTracking

func (qs *QuerySamples) InitStepTracking(start, end, interval int64)

func (*QuerySamples) NewChild

func (qs *QuerySamples) NewChild() *QuerySamples

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

func NewSpanTimer(ctx context.Context, operation string, timer *Timer, observers ...prometheus.Observer) (*SpanTimer, context.Context)

func (*SpanTimer) Finish

func (s *SpanTimer) Finish()

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) Duration

func (t *Timer) Duration() float64

Duration returns the duration value of the timer in seconds.

func (*Timer) ElapsedTime

func (t *Timer) ElapsedTime() time.Duration

ElapsedTime returns the time that passed since starting the timer.

func (*Timer) Start

func (t *Timer) Start() *Timer

Start the timer.

func (*Timer) Stop

func (t *Timer) Stop()

Stop the timer.

func (*Timer) String

func (t *Timer) String() string

Return a string representation of 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 NewTimerGroup

func NewTimerGroup() *TimerGroup

NewTimerGroup constructs a new TimerGroup.

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.

type Timers

type Timers []*Timer

Timers is a slice of Timer pointers that implements Len and Swap from sort.Interface.

func (Timers) Len

func (t Timers) Len() int

Len implements sort.Interface.

func (Timers) Swap

func (t Timers) Swap(i, j int)

Swap implements sort.Interface.

type TotalSamplesPerStep

type TotalSamplesPerStep map[int64]int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL