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

Function pickSchema

prometheus/histogram.go:1462–1475  ·  view source on GitHub ↗

pickSchema returns the largest number n between -4 and 8 such that 2^(2^-n) is less or equal the provided bucketFactor. Special cases: - bucketFactor <= 1: panics. - bucketFactor < 2^(2^-8) (but > 1): still returns 8.

(bucketFactor float64)

Source from the content-addressed store, hash-verified

1460// - bucketFactor <= 1: panics.
1461// - bucketFactor < 2^(2^-8) (but > 1): still returns 8.
1462func pickSchema(bucketFactor float64) int32 {
1463 if bucketFactor <= 1 {
1464 panic(fmt.Errorf("bucketFactor %f is <=1", bucketFactor))
1465 }
1466 floor := math.Floor(math.Log2(math.Log2(bucketFactor)))
1467 switch {
1468 case floor <= -8:
1469 return nativeHistogramSchemaMaximum
1470 case floor >= 4:
1471 return nativeHistogramSchemaMinimum
1472 default:
1473 return -int32(floor)
1474 }
1475}
1476
1477func makeBuckets(buckets *sync.Map) ([]*dto.BucketSpan, []int64) {
1478 var ii []int

Callers 1

newHistogramFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected