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

Method update

prometheus/go_collector_latest.go:509–530  ·  view source on GitHub ↗

update updates the batchHistogram from a runtime/metrics histogram. sum must be provided if the batchHistogram was created to have an exact sum. h.buckets must be a strict subset of his.Buckets.

(his *metrics.Float64Histogram, sum float64)

Source from the content-addressed store, hash-verified

507// sum must be provided if the batchHistogram was created to have an exact sum.
508// h.buckets must be a strict subset of his.Buckets.
509func (h *batchHistogram) update(his *metrics.Float64Histogram, sum float64) {
510 counts, buckets := his.Counts, his.Buckets
511
512 h.mu.Lock()
513 defer h.mu.Unlock()
514
515 // Clear buckets.
516 for i := range h.counts {
517 h.counts[i] = 0
518 }
519 // Copy and reduce buckets.
520 var j int
521 for i, count := range counts {
522 h.counts[j] += count
523 if buckets[i+1] == h.buckets[j+1] {
524 j++
525 }
526 }
527 if h.hasSum {
528 h.sum = sum
529 }
530}
531
532func (h *batchHistogram) Desc() *Desc {
533 return h.desc

Callers 1

CollectMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected