histogram

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Percentile

func Percentile(p float64, buckets Buckets) (float64, error)

Percentile calculates the percentile `p` based on the buckets. The buckets will be sorted by this function (i.e. no sorting needed before calling this function). The percentile value is interpolated assuming a linear distribution within a bucket. However, if the percentile falls into the highest bucket, the upper bound of the 2nd highest bucket is returned. A natural lower bound of 0 is assumed if the upper bound of the lowest bucket is greater 0. In that case, interpolation in the lowest bucket happens linearly between 0 and the upper bound of the lowest bucket. However, if the lowest bucket has an upper bound less or equal to 0, this upper bound is returned if the percentile falls into the lowest bucket.

An error is returned if:

  • `buckets` has fewer than 2 elements
  • the highest bucket is not +Inf
  • p<0
  • p>100

Types

type Bucket

type Bucket struct {
	UpperBound float64
	Count      float64
}

Bucket represents a single grouping of values from Prometheus histogram metrics.

type Buckets

type Buckets []Bucket

Buckets implements sort.Interface.

func (Buckets) Len

func (b Buckets) Len() int

func (Buckets) Less

func (b Buckets) Less(i, j int) bool

func (Buckets) Swap

func (b Buckets) Swap(i, j int)

Jump to

Keyboard shortcuts

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