MCPcopy Create free account
hub / github.com/cortexproject/cortex / AddHistogramData

Method AddHistogramData

pkg/util/metrics_helper.go:499–511  ·  view source on GitHub ↗

AddHistogramData merges another histogram data into this one. Do not call this function after Metric() has been invoked, because histogram created by Metric is using the buckets map (doesn't make a copy), and it's not allowed to change the buckets after they've been passed to a prometheus.Metric.

(histo HistogramData)

Source from the content-addressed store, hash-verified

497// is using the buckets map (doesn't make a copy), and it's not allowed to change the buckets
498// after they've been passed to a prometheus.Metric.
499func (d *HistogramData) AddHistogramData(histo HistogramData) {
500 d.sampleCount += histo.sampleCount
501 d.sampleSum += histo.sampleSum
502
503 if len(histo.buckets) > 0 && d.buckets == nil {
504 d.buckets = map[float64]uint64{}
505 }
506
507 for bound, count := range histo.buckets {
508 // we assume that all histograms have same buckets
509 d.buckets[bound] += count
510 }
511}
512
513// Metric returns prometheus metric from this histogram data.
514//

Callers 2

CopyMethod · 0.95
AddMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected