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)
| 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. |
| 499 | func (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 | // |