add inf
This commit is contained in:
parent
60fb01a811
commit
8466104303
10
histogram.go
10
histogram.go
@ -233,11 +233,15 @@ func (h *Histogram) marshalTo(prefix string, w io.Writer) {
|
||||
}
|
||||
func (h *Histogram) marshalToPrometheus(prefix string, w io.Writer) {
|
||||
countTotal := uint64(0)
|
||||
inf := false
|
||||
h.VisitNonZeroBuckets(func(vmrange string, count uint64) {
|
||||
v := strings.Split(vmrange, "...")
|
||||
if len(v) != 2 {
|
||||
return
|
||||
}
|
||||
if v[1] == "+Inf" {
|
||||
inf = true
|
||||
}
|
||||
tag := fmt.Sprintf("le=%q", v[1])
|
||||
metricName := addTag(prefix, tag)
|
||||
name, labels := splitMetricName(metricName)
|
||||
@ -247,6 +251,12 @@ func (h *Histogram) marshalToPrometheus(prefix string, w io.Writer) {
|
||||
if countTotal == 0 {
|
||||
return
|
||||
}
|
||||
if !inf {
|
||||
tag := fmt.Sprintf("le=%q", "+Inf")
|
||||
metricName := addTag(prefix, tag)
|
||||
name, labels := splitMetricName(metricName)
|
||||
fmt.Fprintf(w, "%s_bucket%s %d\n", name, labels, countTotal)
|
||||
}
|
||||
name, labels := splitMetricName(prefix)
|
||||
sum := h.getSum()
|
||||
if float64(int64(sum)) == sum {
|
||||
|
Loading…
x
Reference in New Issue
Block a user