exemplar

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package exemplar provides an implementation of the OpenTelemetry exemplar reservoir to be used in metric collection pipelines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reservoir

type Reservoir[N int64 | float64] interface {
	// Offer accepts the parameters associated with a measurement. The
	// parameters will be stored as an exemplar if the Reservoir decides to
	// sample the measurement.
	//
	// The passed ctx needs to contain any baggage or span that were active
	// when the measurement was made. This information may be used by the
	// Reservoir in making a sampling decision.
	//
	// The time t is the time when the measurement was made. The val and attr
	// parameters are the value and dropped (filtered) attributes of the
	// measurement respectively.
	Offer(ctx context.Context, t time.Time, val N, attr []attribute.KeyValue)

	// Collect returns all the held exemplars.
	//
	// The Reservoir state is preserved after this call.
	Collect(dest *[]metricdata.Exemplar[N])
}

Reservoir holds the sampled exemplar of measurements made.

func Drop

func Drop[N int64 | float64]() Reservoir[N]

Drop returns a Reservoir that drops all measurements it is offered.

func FixedSize

func FixedSize[N int64 | float64](k int) Reservoir[N]

FixedSize returns a Reservoir that samples at most k exemplars. If there are k or less measurements made, the Reservoir will sample each one. If there are more than k, the Reservoir will then randomly sample all additional measurement with a decreasing probability.

func Histogram

func Histogram[N int64 | float64](bounds []float64) Reservoir[N]

Histogram returns a Reservoir that samples the last measurement that falls within a histogram bucket. The histogram bucket upper-boundaries are define by bounds.

The passed bounds will be sorted by this function.

func SampledFilter

func SampledFilter[N int64 | float64](r Reservoir[N]) Reservoir[N]

SampledFilter returns a Reservoir wrapping r that will only offer measurements to r if the passed context associated with the measurement contains a sampled go.opentelemetry.io/otel/trace.SpanContext.

Jump to

Keyboard shortcuts

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