Documentation ¶
Overview ¶
Package expo implements various operations on exponential histograms and their bucket counts
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Collapse ¶
func Collapse(bs Buckets)
Collapse merges adjacent buckets and zeros the remaining area:
before: 1 1 1 1 1 1 1 1 1 1 1 1 after: 2 2 2 2 2 2 0 0 0 0 0 0
Due to the "perfect subsetting" property of exponential histograms, this gives the same observation as before, but recorded at scale-1. See https://opentelemetry.io/docs/specs/otel/metrics/data-model/#exponential-scale.
Because every bucket now spans twice as much range, half of the allocated counts slice is technically no longer required. It is zeroed but left in place to avoid future allocations, because observations may happen in that area at a later time.
func HiLo ¶
HiLo returns the greater of a and b by comparing the result of applying fn to each. If equal, returns operands as passed
Types ¶
type Absolute ¶
type Absolute struct {
// contains filtered or unexported fields
}
Absolute addresses bucket counts using an absolute scale, such that it is interoperable with Scale.
It spans from [Absolute.Lower:Absolute.Upper]
NOTE: The zero-value is unusable, use Abs to construct
Example ¶
package main import ( "fmt" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/data/expo" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/data/expo/expotest" ) func main() { nums := []float64{0.4, 2.3, 2.4, 4.5} bs := expotest.Observe0(nums...) abs := expo.Abs(bs) s := expo.Scale(0) for _, n := range nums { fmt.Printf("%.1f belongs to bucket %+d\n", n, s.Idx(n)) } fmt.Printf("\n index:") for i := 0; i < bs.BucketCounts().Len(); i++ { fmt.Printf(" %d", i) } fmt.Printf("\n abs:") for i := abs.Lower(); i < abs.Upper(); i++ { fmt.Printf(" %+d", i) } fmt.Printf("\ncounts:") for i := abs.Lower(); i < abs.Upper(); i++ { fmt.Printf(" %d", abs.Abs(i)) } }
Output: 0.4 belongs to bucket -2 2.3 belongs to bucket +1 2.4 belongs to bucket +1 4.5 belongs to bucket +2 index: 0 1 2 3 4 abs: -2 -1 +0 +1 +2 counts: 1 0 0 2 1
type Buckets ¶
type Buckets = pmetric.ExponentialHistogramDataPointBuckets
type DataPoint ¶
type DataPoint = pmetric.ExponentialHistogramDataPoint