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) {
|
func (h *Histogram) marshalToPrometheus(prefix string, w io.Writer) {
|
||||||
countTotal := uint64(0)
|
countTotal := uint64(0)
|
||||||
|
inf := false
|
||||||
h.VisitNonZeroBuckets(func(vmrange string, count uint64) {
|
h.VisitNonZeroBuckets(func(vmrange string, count uint64) {
|
||||||
v := strings.Split(vmrange, "...")
|
v := strings.Split(vmrange, "...")
|
||||||
if len(v) != 2 {
|
if len(v) != 2 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if v[1] == "+Inf" {
|
||||||
|
inf = true
|
||||||
|
}
|
||||||
tag := fmt.Sprintf("le=%q", v[1])
|
tag := fmt.Sprintf("le=%q", v[1])
|
||||||
metricName := addTag(prefix, tag)
|
metricName := addTag(prefix, tag)
|
||||||
name, labels := splitMetricName(metricName)
|
name, labels := splitMetricName(metricName)
|
||||||
@ -247,6 +251,12 @@ func (h *Histogram) marshalToPrometheus(prefix string, w io.Writer) {
|
|||||||
if countTotal == 0 {
|
if countTotal == 0 {
|
||||||
return
|
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)
|
name, labels := splitMetricName(prefix)
|
||||||
sum := h.getSum()
|
sum := h.getSum()
|
||||||
if float64(int64(sum)) == sum {
|
if float64(int64(sum)) == sum {
|
||||||
|
Loading…
Reference in New Issue
Block a user