You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-13 01:00:22 +02:00
Add Aggregation.Kind()
This commit is contained in:
@ -27,6 +27,9 @@ import (
|
||||
type (
|
||||
// Aggregation is an interface returned by the Aggregator
|
||||
// containing an interval of metric data.
|
||||
//
|
||||
// Note that the interfaces below do not embed this interface.
|
||||
// Aggregators are expected to
|
||||
Aggregation interface {
|
||||
// Kind returns a short identifying string to identify
|
||||
// the Aggregator that was used to produce the
|
||||
@ -36,37 +39,44 @@ type (
|
||||
|
||||
// Sum returns an aggregated sum.
|
||||
Sum interface {
|
||||
Aggregation
|
||||
Sum() (metric.Number, error)
|
||||
}
|
||||
|
||||
// Sum returns the number of values that were aggregated.
|
||||
Count interface {
|
||||
Aggregation
|
||||
Count() (int64, error)
|
||||
}
|
||||
|
||||
// Min returns the minimum value over the set of values that were aggregated.
|
||||
Min interface {
|
||||
Aggregation
|
||||
Min() (metric.Number, error)
|
||||
}
|
||||
|
||||
// Max returns the maximum value over the set of values that were aggregated.
|
||||
Max interface {
|
||||
Aggregation
|
||||
Max() (metric.Number, error)
|
||||
}
|
||||
|
||||
// Quantile returns an exact or estimated quantile over the
|
||||
// set of values that were aggregated.
|
||||
Quantile interface {
|
||||
Aggregation
|
||||
Quantile(float64) (metric.Number, error)
|
||||
}
|
||||
|
||||
// LastValue returns the latest value that was aggregated.
|
||||
LastValue interface {
|
||||
Aggregation
|
||||
LastValue() (metric.Number, time.Time, error)
|
||||
}
|
||||
|
||||
// Points returns the raw set of values that were aggregated.
|
||||
Points interface {
|
||||
Aggregation
|
||||
Points() ([]metric.Number, error)
|
||||
}
|
||||
|
||||
@ -87,23 +97,29 @@ type (
|
||||
|
||||
// Histogram returns the count of events in pre-determined buckets.
|
||||
Histogram interface {
|
||||
Sum
|
||||
Aggregation
|
||||
Sum() (metric.Number, error)
|
||||
Histogram() (Buckets, error)
|
||||
}
|
||||
|
||||
// MinMaxSumCount supports the Min, Max, Sum, and Count interfaces.
|
||||
MinMaxSumCount interface {
|
||||
Min
|
||||
Max
|
||||
Sum
|
||||
Count
|
||||
Aggregation
|
||||
Min() (metric.Number, error)
|
||||
Max() (metric.Number, error)
|
||||
Sum() (metric.Number, error)
|
||||
Count() (int64, error)
|
||||
}
|
||||
|
||||
// Distribution supports the Min, Max, Sum, Count, and Quantile
|
||||
// interfaces.
|
||||
Distribution interface {
|
||||
MinMaxSumCount
|
||||
Quantile
|
||||
Aggregation
|
||||
Min() (metric.Number, error)
|
||||
Max() (metric.Number, error)
|
||||
Sum() (metric.Number, error)
|
||||
Count() (int64, error)
|
||||
Quantile(float64) (metric.Number, error)
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -53,6 +53,11 @@ func New() *Aggregator {
|
||||
return &Aggregator{}
|
||||
}
|
||||
|
||||
// Kind returns aggregation.ExactKind.
|
||||
func (c *Aggregator) Kind() aggregation.Kind {
|
||||
return aggregation.ExactKind
|
||||
}
|
||||
|
||||
// Sum returns the sum of values in the checkpoint.
|
||||
func (c *Aggregator) Sum() (metric.Number, error) {
|
||||
return c.ckptSum, nil
|
||||
|
@ -52,6 +52,11 @@ func New(desc *metric.Descriptor, cfg *Config) *Aggregator {
|
||||
}
|
||||
}
|
||||
|
||||
// Kind returns aggregation.SketchKind.
|
||||
func (c *Aggregator) Kind() aggregation.Kind {
|
||||
return aggregation.SketchKind
|
||||
}
|
||||
|
||||
// NewDefaultConfig returns a new, default DDSketch config.
|
||||
//
|
||||
// TODO: Should the Config constructor set minValue to -Inf to
|
||||
|
@ -80,6 +80,11 @@ func New(desc *metric.Descriptor, boundaries []float64) *Aggregator {
|
||||
}
|
||||
}
|
||||
|
||||
// Kind returns aggregation.HistogramKind.
|
||||
func (c *Aggregator) Kind() aggregation.Kind {
|
||||
return aggregation.HistogramKind
|
||||
}
|
||||
|
||||
// Sum returns the sum of all values in the checkpoint.
|
||||
func (c *Aggregator) Sum() (metric.Number, error) {
|
||||
c.lock.Lock()
|
||||
|
@ -68,6 +68,11 @@ func New() *Aggregator {
|
||||
}
|
||||
}
|
||||
|
||||
// Kind returns aggregation.LastValueKind.
|
||||
func (g *Aggregator) Kind() aggregation.Kind {
|
||||
return aggregation.LastValueKind
|
||||
}
|
||||
|
||||
// LastValue returns the last-recorded lastValue value and the
|
||||
// corresponding timestamp. The error value aggregation.ErrNoData
|
||||
// will be returned if (due to a race condition) the checkpoint was
|
||||
|
@ -63,6 +63,11 @@ func New(desc *metric.Descriptor) *Aggregator {
|
||||
}
|
||||
}
|
||||
|
||||
// Kind returns aggregation.MinMaxSumCountKind.
|
||||
func (c *Aggregator) Kind() aggregation.Kind {
|
||||
return aggregation.MinMaxSumCountKind
|
||||
}
|
||||
|
||||
// Sum returns the sum of values in the checkpoint.
|
||||
func (c *Aggregator) Sum() (metric.Number, error) {
|
||||
c.lock.Lock()
|
||||
|
@ -44,6 +44,11 @@ func New() *Aggregator {
|
||||
return &Aggregator{}
|
||||
}
|
||||
|
||||
// Kind returns aggregation.SumKind.
|
||||
func (c *Aggregator) Kind() aggregation.Kind {
|
||||
return aggregation.SumKind
|
||||
}
|
||||
|
||||
// Sum returns the last-checkpointed sum. This will never return an
|
||||
// error.
|
||||
func (c *Aggregator) Sum() (metric.Number, error) {
|
||||
|
Reference in New Issue
Block a user