metrics

package
v0.25.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 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 = NewSampleAndWaterMarkHistogramsVec(clock.RealClock{}, time.Millisecond,
		&compbasemetrics.HistogramOpts{
			Namespace:      namespace,
			Subsystem:      subsystem,
			Name:           "priority_level_seat_count_samples",
			Help:           "Periodic observations of number of seats occupied 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, 1},
			ConstLabels:    map[string]string{phase: "executing"},
			StabilityLevel: compbasemetrics.ALPHA,
		},
		&compbasemetrics.HistogramOpts{
			Namespace:      namespace,
			Subsystem:      subsystem,
			Name:           "priority_level_seat_count_watermarks",
			Help:           "Watermarks of the number of seats occupied 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, 1},
			ConstLabels:    map[string]string{phase: "executing"},
			StabilityLevel: compbasemetrics.ALPHA,
		},
		[]string{priorityLevel},
	)
	// PriorityLevelConcurrencyGaugeVec creates gauges of concurrency broken down by phase, priority level
	PriorityLevelConcurrencyGaugeVec = NewSampleAndWaterMarkHistogramsVec(clock.RealClock{}, time.Millisecond,
		&compbasemetrics.HistogramOpts{
			Namespace:      namespace,
			Subsystem:      subsystem,
			Name:           "priority_level_request_count_samples",
			Help:           "Periodic observations of the number of requests waiting or in 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, 1},
			StabilityLevel: compbasemetrics.ALPHA,
		},
		&compbasemetrics.HistogramOpts{
			Namespace:      namespace,
			Subsystem:      subsystem,
			Name:           "priority_level_request_count_watermarks",
			Help:           "Watermarks of the number of requests waiting or in 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, 1},
			StabilityLevel: compbasemetrics.ALPHA,
		},
		[]string{LabelNamePhase, priorityLevel},
	)
	// ReadWriteConcurrencyGaugeVec creates gauges of number of requests broken down by phase and mutating vs readonly
	ReadWriteConcurrencyGaugeVec = NewSampleAndWaterMarkHistogramsVec(clock.RealClock{}, time.Millisecond,
		&compbasemetrics.HistogramOpts{
			Namespace:      namespace,
			Subsystem:      subsystem,
			Name:           "read_vs_write_request_count_samples",
			Help:           "Periodic observations of the number of requests waiting or in regular stage of execution",
			Buckets:        []float64{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
			StabilityLevel: compbasemetrics.ALPHA,
		},
		&compbasemetrics.HistogramOpts{
			Namespace:      namespace,
			Subsystem:      subsystem,
			Name:           "read_vs_write_request_count_watermarks",
			Help:           "Watermarks of the number of requests waiting or in regular stage of execution",
			Buckets:        []float64{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
			StabilityLevel: compbasemetrics.ALPHA,
		},
		[]string{LabelNamePhase, requestKind},
	)
)

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 SampleAndWaterMarkObserverVec

type SampleAndWaterMarkObserverVec struct {
	// contains filtered or unexported fields
}

SampleAndWaterMarkObserverVec creates RatioedGauges that populate histograms of samples and low- and high-water-marks. The generator has a samplePeriod, and the histograms get an observation every samplePeriod. The sampling windows are quantized based on the monotonic rather than wall-clock times. The `t0` field is there so to provide a baseline for monotonic clock differences.

func NewSampleAndWaterMarkHistogramsVec

func NewSampleAndWaterMarkHistogramsVec(clock clock.PassiveClock, samplePeriod time.Duration, sampleOpts, waterMarkOpts *compbasemetrics.HistogramOpts, labelNames []string) SampleAndWaterMarkObserverVec

NewSampleAndWaterMarkHistogramsVec makes a new one

func (SampleAndWaterMarkObserverVec) NewForLabelValuesSafe

func (swg SampleAndWaterMarkObserverVec) NewForLabelValuesSafe(initialNumerator, initialDenominator float64, labelValues []string) RatioedGauge

NewForLabelValuesSafe makes a new RatioedGauge

Jump to

Keyboard shortcuts

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