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

Function newBatchHistogram

prometheus/go_collector_latest.go:485–503  ·  view source on GitHub ↗

newBatchHistogram creates a new batch histogram value with the given Desc, buckets, and whether or not it has an exact sum available. buckets must always be from the runtime/metrics package, following the same conventions.

(desc *Desc, buckets []float64, hasSum bool)

Source from the content-addressed store, hash-verified

483// buckets must always be from the runtime/metrics package, following
484// the same conventions.
485func newBatchHistogram(desc *Desc, buckets []float64, hasSum bool) *batchHistogram {
486 // We need to remove -Inf values. runtime/metrics keeps them around.
487 // But -Inf bucket should not be allowed for prometheus histograms.
488 if buckets[0] == math.Inf(-1) {
489 buckets = buckets[1:]
490 }
491 h := &batchHistogram{
492 desc: desc,
493 buckets: buckets,
494 // Because buckets follows runtime/metrics conventions, there's
495 // 1 more value in the buckets list than there are buckets represented,
496 // because in runtime/metrics, the bucket values represent *boundaries*,
497 // and non-Inf boundaries are inclusive lower bounds for that bucket.
498 counts: make([]uint64, len(buckets)-1),
499 hasSum: hasSum,
500 }
501 h.init(h)
502 return h
503}
504
505// update updates the batchHistogram from a runtime/metrics histogram.
506//

Callers 1

NewGoCollectorFunction · 0.85

Calls 1

initMethod · 0.80

Tested by

no test coverage detected