Marshal integer *_sum
metric for Summary without scientific notation
This commit is contained in:
parent
c68df4bc3d
commit
b9f1652800
2
gauge.go
2
gauge.go
@ -37,7 +37,7 @@ func (g *Gauge) Get() float64 {
|
|||||||
func (g *Gauge) marshalTo(prefix string, w io.Writer) {
|
func (g *Gauge) marshalTo(prefix string, w io.Writer) {
|
||||||
v := g.f()
|
v := g.f()
|
||||||
if float64(int64(v)) == v {
|
if float64(int64(v)) == v {
|
||||||
// Marshal integer values without scientific notations
|
// Marshal integer values without scientific notation
|
||||||
fmt.Fprintf(w, "%s %d\n", prefix, int64(v))
|
fmt.Fprintf(w, "%s %d\n", prefix, int64(v))
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(w, "%s %g\n", prefix, v)
|
fmt.Fprintf(w, "%s %g\n", prefix, v)
|
||||||
|
@ -109,7 +109,12 @@ func (sm *Summary) marshalTo(prefix string, w io.Writer) {
|
|||||||
|
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
name, filters := splitMetricName(prefix)
|
name, filters := splitMetricName(prefix)
|
||||||
|
if float64(int64(sum)) == sum {
|
||||||
|
// Marshal integer sum without scientific notation
|
||||||
|
fmt.Fprintf(w, "%s_sum%s %d\n", name, filters, int64(sum))
|
||||||
|
} else {
|
||||||
fmt.Fprintf(w, "%s_sum%s %g\n", name, filters, sum)
|
fmt.Fprintf(w, "%s_sum%s %g\n", name, filters, sum)
|
||||||
|
}
|
||||||
fmt.Fprintf(w, "%s_count%s %d\n", name, filters, count)
|
fmt.Fprintf(w, "%s_count%s %d\n", name, filters, count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user