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

Function ExponentialBuckets

prometheus/histogram.go:315–331  ·  view source on GitHub ↗

ExponentialBuckets creates 'count' regular buckets, where the lowest bucket has an upper bound of 'start' and each following bucket's upper bound is 'factor' times the previous bucket's upper bound. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is me

(start, factor float64, count int)

Source from the content-addressed store, hash-verified

313// The function panics if 'count' is 0 or negative, if 'start' is 0 or negative,
314// or if 'factor' is less than or equal 1.
315func ExponentialBuckets(start, factor float64, count int) []float64 {
316 if count < 1 {
317 panic("ExponentialBuckets needs a positive count")
318 }
319 if start <= 0 {
320 panic("ExponentialBuckets needs a positive start value")
321 }
322 if factor <= 1 {
323 panic("ExponentialBuckets needs a factor greater than 1")
324 }
325 buckets := make([]float64, count)
326 for i := range buckets {
327 buckets[i] = start
328 start *= factor
329 }
330 return buckets
331}
332
333// ExponentialBucketsRange creates 'count' buckets, where the lowest bucket is
334// 'min' and the highest bucket is 'max'. The final +Inf bucket is not counted

Callers 5

NewFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
TestBucketsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestBucketsFunction · 0.68