metrics

package
v0.25.13 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 11 Imported by: 8

Documentation

Index

Constants

View Source
const (
	LabelNamePhase      = "phase"
	LabelValueWaiting   = "waiting"
	LabelValueExecuting = "executing"
)

Variables

View Source
var (

	// PriorityLevelExecutionSeatsGaugeVec creates observers of seats occupied throughout execution for priority levels
	PriorityLevelExecutionSeatsGaugeVec = NewTimingRatioHistogramVec(
		&compbasemetrics.TimingHistogramOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "priority_level_seat_utilization",
			Help:      "Observations, at the end of every nanosecond, of utilization of seats for any stage of execution (but only initial stage for WATCHes)",

			Buckets:        []float64{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 1},
			ConstLabels:    map[string]string{phase: "executing"},
			StabilityLevel: compbasemetrics.ALPHA,
		},
		priorityLevel,
	)
	// PriorityLevelConcurrencyGaugeVec creates gauges of concurrency broken down by phase, priority level
	PriorityLevelConcurrencyGaugeVec = NewTimingRatioHistogramVec(
		&compbasemetrics.TimingHistogramOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "priority_level_request_utilization",
			Help:      "Observations, at the end of every nanosecond, of number of requests (as a fraction of the relevant limit) waiting or in any stage of execution (but only initial stage for WATCHes)",

			Buckets:        []float64{0, 0.001, 0.003, 0.01, 0.03, 0.1, 0.25, 0.5, 0.75, 1},
			StabilityLevel: compbasemetrics.ALPHA,
		},
		LabelNamePhase, priorityLevel,
	)
)
View Source
var GetExecutingMutatingConcurrency = executingMutating.getGauge

GetExecutingMutatingConcurrency returns the gauge of number of executing mutating requests / limit on those.

View Source
var GetExecutingReadonlyConcurrency = executingReadonly.getGauge

GetExecutingReadonlyConcurrency returns the gauge of number of executing readonly requests / limit on those.

View Source
var GetWaitingMutatingConcurrency = waitingMutating.getGauge

GetWaitingMutatingConcurrency returns the gauge of number of mutating requests waiting / limit on those.

View Source
var GetWaitingReadonlyConcurrency = waitingReadonly.getGauge

GetWaitingReadonlyConcurrency returns the gauge of number of readonly requests waiting / limit on those.

Functions

func AddDispatch added in v0.18.0

func AddDispatch(ctx context.Context, priorityLevel, flowSchema string)

AddDispatch increments the # of dispatched requests for flow control

func AddDispatchWithNoAccommodation added in v0.24.0

func AddDispatchWithNoAccommodation(priorityLevel, flowSchema string)

AddDispatchWithNoAccommodation keeps track of number of times dispatch attempt results in a non accommodation due to lack of available seats.

func AddEpochAdvance added in v0.23.0

func AddEpochAdvance(ctx context.Context, priorityLevel string, success bool)

AddEpochAdvance notes an advance of the progress meter baseline for a given priority level

func AddReject

func AddReject(ctx context.Context, priorityLevel, flowSchema, reason string)

AddReject increments the # of rejected requests for flow control

func AddRequestConcurrencyInUse added in v0.22.0

func AddRequestConcurrencyInUse(priorityLevel, flowSchema string, delta int)

AddRequestConcurrencyInUse adds the given delta to the gauge of concurrency in use by the currently executing requests of the given flowSchema and priorityLevel

func AddRequestsExecuting added in v0.18.0

func AddRequestsExecuting(ctx context.Context, priorityLevel, flowSchema string, delta int)

AddRequestsExecuting adds the given delta to the gauge of executing requests of the given flowSchema and priorityLevel

func AddRequestsInQueues added in v0.18.0

func AddRequestsInQueues(ctx context.Context, priorityLevel, flowSchema string, delta int)

AddRequestsInQueues adds the given delta to the gauge of the # of requests in the queues of the specified flowSchema and priorityLevel

func GatherAndCompare added in v0.18.0

func GatherAndCompare(expected string, metricNames ...string) error

GatherAndCompare the given metrics with the given Prometheus syntax expected value

func ObserveExecutionDuration

func ObserveExecutionDuration(ctx context.Context, priorityLevel, flowSchema string, executionTime time.Duration)

ObserveExecutionDuration observes the execution duration for flow control

func ObserveQueueLength

func ObserveQueueLength(ctx context.Context, priorityLevel, flowSchema string, length int)

ObserveQueueLength observes the queue length for flow control

func ObserveWaitingDuration

func ObserveWaitingDuration(ctx context.Context, priorityLevel, flowSchema, execute string, waitTime time.Duration)

ObserveWaitingDuration observes the queue length for flow control

func ObserveWatchCount added in v0.23.0

func ObserveWatchCount(ctx context.Context, priorityLevel, flowSchema string, count int)

ObserveWatchCount notes a sampling of a watch count

func ObserveWorkEstimatedSeats added in v0.24.0

func ObserveWorkEstimatedSeats(priorityLevel, flowSchema string, seats int)

ObserveWorkEstimatedSeats notes a sampling of estimated seats associated with a request

func Register added in v0.18.0

func Register()

Register all metrics.

func Reset added in v0.18.0

func Reset()

Reset all metrics to zero

func SetCurrentR added in v0.22.0

func SetCurrentR(priorityLevel string, r float64)

SetCurrentR sets the current-R (virtualTime) gauge for the given priority level

func SetDispatchMetrics added in v0.22.0

func SetDispatchMetrics(priorityLevel string, r, s, sMin, sMax, discountedSMin, discountedSMax float64)

SetLatestS sets the latest-S (virtual time of dispatched request) gauge for the given priority level

func UpdateSharedConcurrencyLimit

func UpdateSharedConcurrencyLimit(priorityLevel string, limit int)

UpdateSharedConcurrencyLimit updates the value for the concurrency limit in flow control

Types

type Gauge added in v0.25.0

type Gauge interface {
	Set(float64)
	Inc()
	Dec()
	Add(float64)
	SetToCurrentTime()
}

Gauge is the methods of a gauge that are used by instrumented code.

type RatioedGauge added in v0.25.0

type RatioedGauge interface {
	Gauge

	// SetDenominator sets the denominator to use until it is changed again
	SetDenominator(float64)
}

RatioedGauge tracks ratios. The numerator is set/changed through the Gauge methods, and the denominator can be updated through the SetDenominator method. A ratio is tracked whenever the numerator or denominator is set/changed.

type RatioedGaugePair added in v0.25.0

type RatioedGaugePair struct {
	// RequestsWaiting is given observations of the number of currently queued requests
	RequestsWaiting RatioedGauge

	// RequestsExecuting is given observations of the number of requests currently executing
	RequestsExecuting RatioedGauge
}

RatioedGaugePair is a corresponding pair of gauges, one for the number of requests waiting in queue(s) and one for the number of requests being executed.

func RatioedGaugeVecPhasedElementPair added in v0.25.0

func RatioedGaugeVecPhasedElementPair(vec RatioedGaugeVec, initialWaitingDenominator, initialExecutingDenominator float64, labelValues []string) RatioedGaugePair

RatioedGaugeVecPhasedElementPair extracts a pair of elements that differ in handling phase

type RatioedGaugeVec added in v0.25.0

type RatioedGaugeVec interface {
	// NewForLabelValuesSafe makes a new vector member for the given tuple of label values,
	// initialized with the given numerator and denominator.
	// Unlike the usual Vec WithLabelValues method, this is intended to be called only
	// once per vector member (at the start of its lifecycle).
	// The "Safe" part is saying that the returned object will function properly after metric registration
	// even if this method is called before registration.
	NewForLabelValuesSafe(initialNumerator, initialDenominator float64, labelValues []string) RatioedGauge
}

RatioedGaugeVec creates related observers that are differentiated by a series of label values

type Registerables added in v0.19.0

type Registerables []compbasemetrics.Registerable

Registerables is a slice of Registerable

func (Registerables) Append added in v0.19.0

Append adds more

type TimingRatioHistogram added in v0.25.0

type TimingRatioHistogram struct {

	// Registerable is the registerable aspect.
	// That is the registerable aspect of the underlying TimingHistogram.
	compbasemetrics.Registerable
	// contains filtered or unexported fields
}

TimingRatioHistogram is essentially a gauge for a ratio where the client independently controls the numerator and denominator. When scraped it produces a histogram of samples of the ratio taken at the end of every nanosecond. `*TimingRatioHistogram` implements both Registerable and RatioedGauge.

func NewTestableTimingRatioHistogram added in v0.25.0

func NewTestableTimingRatioHistogram(nowFunc func() time.Time, opts *TimingRatioHistogramOpts) *TimingRatioHistogram

NewTestableTimingHistogram adds injection of the clock

func NewTimingRatioHistogram added in v0.25.0

func NewTimingRatioHistogram(opts *TimingRatioHistogramOpts) *TimingRatioHistogram

NewTimingHistogram returns an object which is TimingHistogram-like. However, nothing will be measured until the histogram is registered in at least one registry.

func (*TimingRatioHistogram) Add added in v0.25.0

func (trh *TimingRatioHistogram) Add(deltaNumerator float64)

func (*TimingRatioHistogram) Dec added in v0.25.0

func (trh *TimingRatioHistogram) Dec()

func (*TimingRatioHistogram) Inc added in v0.25.0

func (trh *TimingRatioHistogram) Inc()

func (*TimingRatioHistogram) Set added in v0.25.0

func (trh *TimingRatioHistogram) Set(numerator float64)

func (*TimingRatioHistogram) SetDenominator added in v0.25.0

func (trh *TimingRatioHistogram) SetDenominator(denominator float64)

func (*TimingRatioHistogram) SetToCurrentTime added in v0.25.0

func (trh *TimingRatioHistogram) SetToCurrentTime()

func (*TimingRatioHistogram) Sub added in v0.25.0

func (trh *TimingRatioHistogram) Sub(deltaNumerator float64)

func (*TimingRatioHistogram) WithContext added in v0.25.0

func (trh *TimingRatioHistogram) WithContext(ctx context.Context) RatioedGauge

WithContext allows the normal TimingHistogram metric to pass in context. The context is no-op at the current level of development.

type TimingRatioHistogramOpts added in v0.25.0

type TimingRatioHistogramOpts struct {
	compbasemetrics.TimingHistogramOpts
	InitialDenominator float64
}

TimingRatioHistogramOpts is the constructor parameters of a TimingRatioHistogram. The `TimingHistogramOpts.InitialValue` is the initial numerator.

type TimingRatioHistogramVec added in v0.25.0

type TimingRatioHistogramVec struct {
	// promote only the Registerable methods
	compbasemetrics.Registerable
	// contains filtered or unexported fields
}

TimingRatioHistogramVec is a collection of TimingRatioHistograms that differ only in label values. `*TimingRatioHistogramVec` implements both Registerable and RatioedGaugeVec.

func NewTestableTimingRatioHistogramVec added in v0.25.0

func NewTestableTimingRatioHistogramVec(nowFunc func() time.Time, opts *compbasemetrics.TimingHistogramOpts, labelNames ...string) *TimingRatioHistogramVec

NewTestableTimingHistogramVec adds injection of the clock.

func NewTimingRatioHistogramVec added in v0.25.0

func NewTimingRatioHistogramVec(opts *compbasemetrics.TimingHistogramOpts, labelNames ...string) *TimingRatioHistogramVec

NewTimingHistogramVec constructs a new vector. `opts.InitialValue` is the initial ratio, but this applies only for the tiny period of time until NewForLabelValuesSafe sets the ratio based on the given initial numerator and denominator. Thus there is a tiny splinter of time during member construction when its underlying TimingHistogram is given the initial numerator rather than the initial ratio (which is obviously a non-issue when both are zero). Note the difficulties associated with extracting a member before registering the vector.

func (*TimingRatioHistogramVec) NewForLabelValuesChecked added in v0.25.0

func (v *TimingRatioHistogramVec) NewForLabelValuesChecked(initialNumerator, initialDenominator float64, labelValues []string) (RatioedGauge, error)

NewForLabelValuesChecked will return an error if this vec is not hidden and not yet registered or there is a syntactic problem with the labelValues.

func (*TimingRatioHistogramVec) NewForLabelValuesSafe added in v0.25.0

func (v *TimingRatioHistogramVec) NewForLabelValuesSafe(initialNumerator, initialDenominator float64, labelValues []string) RatioedGauge

NewForLabelValuesSafe is the same as NewForLabelValuesChecked in cases where that does not return an error. When the unsafe version returns an error due to the vector not being registered yet, the safe version returns an object that implements its methods by looking up the relevant vector member in each call (thus getting a non-noop after registration). In the other error cases the object returned here is a noop.

func (*TimingRatioHistogramVec) Reset added in v0.25.0

func (v *TimingRatioHistogramVec) Reset()

Jump to

Keyboard shortcuts

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