mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Small improvement in handling cases without count
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
This commit is contained in:
parent
872e2db2a9
commit
41f051e9a4
|
@ -139,19 +139,15 @@ func (h TempHistogram) Convert() (*histogram.Histogram, *histogram.FloatHistogra
|
||||||
return nil, nil, h.err
|
return nil, nil, h.err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(h.buckets) == 0 || h.buckets[len(h.buckets)-1].le != math.Inf(1) {
|
if !h.hasCount && len(h.buckets) > 0 {
|
||||||
// No +Inf bucket.
|
// No count, so set count to the highest known bucket's count.
|
||||||
if !h.hasCount && len(h.buckets) > 0 {
|
h.count = h.buckets[len(h.buckets)-1].count
|
||||||
// No count either, so set count to the last known bucket's count.
|
|
||||||
h.count = h.buckets[len(h.buckets)-1].count
|
|
||||||
}
|
|
||||||
// Let the last bucket be +Inf with the overall count.
|
|
||||||
h.buckets = append(h.buckets, tempHistogramBucket{le: math.Inf(1), count: h.count})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !h.hasCount {
|
if len(h.buckets) == 0 || h.buckets[len(h.buckets)-1].le != math.Inf(1) {
|
||||||
h.count = h.buckets[len(h.buckets)-1].count
|
// No +Inf bucket.
|
||||||
h.hasCount = true
|
// Let the last bucket be +Inf with the overall count.
|
||||||
|
h.buckets = append(h.buckets, tempHistogramBucket{le: math.Inf(1), count: h.count})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, b := range h.buckets {
|
for _, b := range h.buckets {
|
||||||
|
|
Loading…
Reference in a new issue