Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

aggregate

v1.47.0
go.opentelemetry.io/otel/sdk/metric/internal/aggregate

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

15 matches

Top ↑

Package aggregate provides aggregate types used compute aggregations and cycle the state of metric measurements made by the SDK. These types and functionality are meant only for internal SDK use.

Types

Builder

type Builder[N int64 | float64] struct {
	// Temporality is the temporality used for the returned aggregate function.
	//
	// If this is not provided a default of cumulative will be used (except for
	// the last-value aggregate function where delta is the only appropriate
	// temporality).
	Temporality metricdata.Temporality
	// Filter is the attribute filter the aggregate function will use on the
	// input of measurements.
	Filter attribute.Filter
	// ReservoirFunc is the factory function used by aggregate functions to
	// create new exemplar reservoirs for a new seen attribute set.
	//
	// If this is not provided a default factory function that returns a
	// DropReservoir reservoir will be used.
	ReservoirFunc func(attribute.Set) FilteredExemplarReservoir[N]
	// AggregationLimit is the cardinality limit of measurement attributes. Any
	// measurement for new attributes once the limit has been reached will be
	// aggregated into a single aggregate for the "otel.metric.overflow"
	// attribute.
	//
	// If AggregationLimit is less than or equal to zero there will not be an
	// aggregation limit imposed (i.e. unlimited attribute sets).
	AggregationLimit int
}

Builder builds an aggregate function.

Builder[N].ExplicitBucketHistogram

func (b Builder[N]) ExplicitBucketHistogram(
	boundaries []float64,
	noMinMax, noSum bool,
) (Measure[N], ComputeAggregation)

ExplicitBucketHistogram returns a histogram aggregate function input and output.

Builder[N].ExponentialBucketHistogram

func (b Builder[N]) ExponentialBucketHistogram(
	maxSize, maxScale int32,
	noMinMax, noSum bool,
) (Measure[N], ComputeAggregation)

ExponentialBucketHistogram returns a histogram aggregate function input and output.

Builder[N].FinishSum

func (b Builder[N]) FinishSum(monotonic bool) FinishSum[N]

FinishSum returns a Sum aggregation with exact-attribute lifecycle support.

Builder[N].LastValue

func (b Builder[N]) LastValue() (Measure[N], ComputeAggregation)

LastValue returns a last-value aggregate function input and output.

Builder[N].PrecomputedLastValue

func (b Builder[N]) PrecomputedLastValue() (Measure[N], ComputeAggregation)

PrecomputedLastValue returns a last-value aggregate function input and output. The aggregation returned from the returned ComputeAggregation function will always only return values from the previous collection cycle.

Builder[N].PrecomputedSum

func (b Builder[N]) PrecomputedSum(monotonic bool) (Measure[N], ComputeAggregation)

PrecomputedSum returns a sum aggregate function input and output. The arguments passed to the input are expected to be the precomputed sum values.

Builder[N].Sum

func (b Builder[N]) Sum(monotonic bool) (Measure[N], ComputeAggregation)

Sum returns a sum aggregate function input and output.

ComputeAggregation

type ComputeAggregation func(dest *metricdata.Aggregation) int

ComputeAggregation stores the aggregate of measurements into dest and returns the number of aggregate data-points output.

FilteredExemplarReservoir

type FilteredExemplarReservoir[N int64 | float64] interface {
	// Offer accepts the parameters associated with a measurement. The
	// parameters will be stored as an exemplar if the filter 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 lazy parameter provides filtered attribute details when sampled,
	// allowing dropped attributes to be computed only if the measurement is sampled.
	Offer(ctx context.Context, val N, lazy lazyFilteredAttributes)
	// Collect returns all the held exemplars in the reservoir.
	Collect(dest *[]exemplar.Exemplar)
}

FilteredExemplarReservoir wraps a exemplar.Reservoir with a filter.

DropReservoir

func DropReservoir[N int64 | float64](attribute.Set) FilteredExemplarReservoir[N]

DropReservoir returns a FilteredExemplarReservoir that drops all measurements it is offered.

NewFilteredExemplarReservoir

func NewFilteredExemplarReservoir[N int64 | float64](
	f exemplar.Filter,
	r exemplar.Reservoir,
) FilteredExemplarReservoir[N]

NewFilteredExemplarReservoir creates a FilteredExemplarReservoir which only offers values that are allowed by the filter.

FinishSum

type FinishSum[N int64 | float64] struct {
	Measure            Measure[N]
	ComputeAggregation ComputeAggregation
	Finish             func(attribute.Distinct, time.Time)
	Shutdown           func()
}

FinishSum contains the operations of a finish-aware Sum aggregation.

Measure

type Measure[N int64 | float64] func(context.Context, N, attribute.Set)

Measure receives measurements to be aggregated.

Dependency graph