MCPcopy
hub / github.com/prometheus/client_golang / LinearBuckets

Function LinearBuckets

prometheus/histogram.go:295–305  ·  view source on GitHub ↗

LinearBuckets creates 'count' regular buckets, each 'width' wide, where the lowest bucket has an upper bound of 'start'. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field of HistogramOpts. The function panics if

(start, width float64, count int)

Source from the content-addressed store, hash-verified

293//
294// The function panics if 'count' is zero or negative.
295func LinearBuckets(start, width float64, count int) []float64 {
296 if count < 1 {
297 panic("LinearBuckets needs a positive count")
298 }
299 buckets := make([]float64, count)
300 for i := range buckets {
301 buckets[i] = start
302 start += width
303 }
304 return buckets
305}
306
307// ExponentialBuckets creates 'count' regular buckets, where the lowest bucket
308// has an upper bound of 'start' and each following bucket's upper bound is

Callers 4

ExampleHistogramFunction · 0.92
NewMetricsFunction · 0.92
TestBucketsFunction · 0.85

Calls

no outgoing calls

Tested by 2

ExampleHistogramFunction · 0.74
TestBucketsFunction · 0.68