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)
| 483 | // buckets must always be from the runtime/metrics package, following |
| 484 | // the same conventions. |
| 485 | func 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 | // |