aggregation

package
Version: v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 5 Imported by: 38

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNegativeInput    = fmt.Errorf("negative value is out of range for this instrument")
	ErrNaNInput         = fmt.Errorf("NaN value is an invalid input")
	ErrInconsistentType = fmt.Errorf("inconsistent aggregator types")

	// ErrNoCumulativeToDelta is returned when requesting delta
	// export kind for a precomputed sum instrument.
	ErrNoCumulativeToDelta = fmt.Errorf("cumulative to delta not implemented")

	// ErrNoData is returned when (due to a race with collection)
	// the Aggregator is check-pointed before the first value is set.
	// The aggregator should simply be skipped in this case.
	ErrNoData = fmt.Errorf("no data collected by this aggregator")
)

Sentinel errors for Aggregation interface.

Functions

This section is empty.

Types

type Aggregation

type Aggregation interface {
	// Kind returns a short identifying string to identify
	// the Aggregator that was used to produce the
	// Aggregation (e.g., "Sum").
	Kind() Kind
}

Aggregation is an interface returned by the Aggregator containing an interval of metric data.

type Buckets

type Buckets struct {
	// Boundaries are floating point numbers, even when
	// aggregating integers.
	Boundaries []float64

	// Counts holds the count in each bucket.
	Counts []uint64
}

Buckets represents histogram buckets boundaries and counts.

For a Histogram with N defined boundaries, e.g, [x, y, z]. There are N+1 counts: [-inf, x), [x, y), [y, z), [z, +inf].

type Count

type Count interface {
	Aggregation
	Count() (uint64, error)
}

Count returns the number of values that were aggregated.

type Histogram

type Histogram interface {
	Aggregation
	Count() (uint64, error)
	Sum() (number.Number, error)
	Histogram() (Buckets, error)
}

Histogram returns the count of events in pre-determined buckets.

type Kind

type Kind string

Kind is a short name for the Aggregator that produces an Aggregation, used for descriptive purpose only. Kind is a string to allow user-defined Aggregators.

When deciding how to handle an Aggregation, Exporters are encouraged to decide based on conversion to the above interfaces based on strength, not on Kind value, when deciding how to expose metric data. This enables user-supplied Aggregators to replace builtin Aggregators.

For example, test for a Histogram before testing for a Sum, and so on.

const (
	SumKind       Kind = "Sum"
	HistogramKind Kind = "Histogram"
	LastValueKind Kind = "Lastvalue"
)

Kind description constants.

func (Kind) String

func (k Kind) String() string

String returns the string value of Kind.

type LastValue

type LastValue interface {
	Aggregation
	LastValue() (number.Number, time.Time, error)
}

LastValue returns the latest value that was aggregated.

type Sum

type Sum interface {
	Aggregation
	Sum() (number.Number, error)
}

Sum returns an aggregated sum.

type Temporality

type Temporality uint8

Temporality indicates the temporal aggregation exported by an exporter. These bits may be OR-d together when multiple exporters are in use.

const (
	// CumulativeTemporality indicates that an Exporter expects a
	// Cumulative Aggregation.
	CumulativeTemporality Temporality = 1

	// DeltaTemporality indicates that an Exporter expects a
	// Delta Aggregation.
	DeltaTemporality Temporality = 2
)

func (Temporality) Includes

func (t Temporality) Includes(other Temporality) bool

Includes returns if t includes support for other temporality.

func (Temporality) MemoryRequired

func (t Temporality) MemoryRequired(mkind sdkapi.InstrumentKind) bool

MemoryRequired returns whether an exporter of this temporality requires memory to export correctly.

func (Temporality) String

func (i Temporality) String() string

type TemporalitySelector

type TemporalitySelector interface {
	// TemporalityFor should return the correct Temporality that
	// should be used when exporting data for the given metric
	// instrument and Aggregator kind.
	TemporalityFor(descriptor *sdkapi.Descriptor, aggregationKind Kind) Temporality
}

TemporalitySelector is a sub-interface of Exporter used to indicate whether the Processor should compute Delta or Cumulative Aggregations.

func ConstantTemporalitySelector

func ConstantTemporalitySelector(t Temporality) TemporalitySelector

ConstantTemporalitySelector returns an TemporalitySelector that returns a constant Temporality.

func CumulativeTemporalitySelector

func CumulativeTemporalitySelector() TemporalitySelector

CumulativeTemporalitySelector returns an TemporalitySelector that always returns CumulativeTemporality.

func DeltaTemporalitySelector

func DeltaTemporalitySelector() TemporalitySelector

DeltaTemporalitySelector returns an TemporalitySelector that always returns DeltaTemporality.

func StatelessTemporalitySelector

func StatelessTemporalitySelector() TemporalitySelector

StatelessTemporalitySelector returns an TemporalitySelector that always returns the Temporality that avoids long-term memory requirements.

Jump to

Keyboard shortcuts

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