metrics

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// PriorityLevelExecutionSeatsObserverGenerator creates observers of seats occupied throughout execution for priority levels
	PriorityLevelExecutionSeatsObserverGenerator = NewSampleAndWaterMarkHistogramsGenerator(clock.RealClock{}, time.Millisecond,
		&compbasemetrics.HistogramOpts{
			Namespace:      namespace,
			Subsystem:      subsystem,
			Name:           "priority_level_seat_count_samples",
			Help:           "Periodic observations of the number of requests",
			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 requests",
			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},
	)
	// PriorityLevelConcurrencyObserverPairGenerator creates pairs that observe concurrency for priority levels
	PriorityLevelConcurrencyObserverPairGenerator = NewSampleAndWaterMarkHistogramsPairGenerator(clock.RealClock{}, time.Millisecond,
		&compbasemetrics.HistogramOpts{
			Namespace:      namespace,
			Subsystem:      subsystem,
			Name:           "priority_level_request_count_samples",
			Help:           "Periodic observations of the number of requests",
			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",
			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{priorityLevel},
	)
	// ReadWriteConcurrencyObserverPairGenerator creates pairs that observe concurrency broken down by mutating vs readonly
	ReadWriteConcurrencyObserverPairGenerator = NewSampleAndWaterMarkHistogramsPairGenerator(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",
			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",
			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{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 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 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 ChangeObserver added in v0.23.0

type ChangeObserver interface {
	Observer

	// Observe a new value that differs by the given amount from the previous observation.
	Add(float64)
}
ChangeObserver extends Observer with the ability to take

an observation that is relative to the previous observation.

type Observer added in v0.23.0

type Observer interface {
	// Observe takes an observation
	Observe(float64)
}

Observer is something that can be given numeric observations.

type RatioedChangeObserver added in v0.23.0

type RatioedChangeObserver interface {
	ChangeObserver

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

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

type RatioedChangeObserverGenerator added in v0.23.0

type RatioedChangeObserverGenerator interface {
	Generate(initialNumerator, initialDenominator float64, labelValues []string) RatioedChangeObserver
}

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

type RatioedChangeObserverPair added in v0.23.0

type RatioedChangeObserverPair struct {
	// RequestsWaiting is given observations of the number of currently queued requests
	RequestsWaiting RatioedChangeObserver

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

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

type RatioedChangeObserverPairGenerator added in v0.23.0

type RatioedChangeObserverPairGenerator interface {
	Generate(initialWaitingDenominator, initialExecutingDenominator float64, labelValues []string) RatioedChangeObserverPair
}

RatioedChangeObserverPairGenerator generates pairs

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 SampleAndWaterMarkObserverGenerator added in v0.19.0

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

SampleAndWaterMarkObserverGenerator creates RatioedChangeObservers 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 NewSampleAndWaterMarkHistogramsGenerator added in v0.19.0

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

NewSampleAndWaterMarkHistogramsGenerator makes a new one

func (SampleAndWaterMarkObserverGenerator) Generate added in v0.19.0

func (swg SampleAndWaterMarkObserverGenerator) Generate(initialNumerator, initialDenominator float64, labelValues []string) RatioedChangeObserver

Generate makes a new RatioedChangeObserver

type SampleAndWaterMarkPairGenerator added in v0.19.0

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

SampleAndWaterMarkPairGenerator makes pairs of RatioedChangeObservers that track samples and watermarks.

func NewSampleAndWaterMarkHistogramsPairGenerator added in v0.19.0

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

NewSampleAndWaterMarkHistogramsPairGenerator makes a new pair generator

func (SampleAndWaterMarkPairGenerator) Generate added in v0.19.0

func (spg SampleAndWaterMarkPairGenerator) Generate(initialWaitingDenominator, initialExecutingDenominator float64, labelValues []string) RatioedChangeObserverPair

Generate makes a new pair

Jump to

Keyboard shortcuts

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