metrics/influxdb: don't push empty histograms, no measurement != 0

pull/22590/head
Péter Szilágyi 4 years ago
parent cae6b5527e
commit 62379f02c6
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
  1. 43
      metrics/influxdb/influxdb.go

@ -162,26 +162,29 @@ func (r *reporter) send() error {
}) })
case metrics.Histogram: case metrics.Histogram:
ms := metric.Snapshot() ms := metric.Snapshot()
ps := ms.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999})
pts = append(pts, client.Point{ if ms.Count() > 0 {
Measurement: fmt.Sprintf("%s%s.histogram", namespace, name), ps := ms.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999})
Tags: r.tags, pts = append(pts, client.Point{
Fields: map[string]interface{}{ Measurement: fmt.Sprintf("%s%s.histogram", namespace, name),
"count": ms.Count(), Tags: r.tags,
"max": ms.Max(), Fields: map[string]interface{}{
"mean": ms.Mean(), "count": ms.Count(),
"min": ms.Min(), "max": ms.Max(),
"stddev": ms.StdDev(), "mean": ms.Mean(),
"variance": ms.Variance(), "min": ms.Min(),
"p50": ps[0], "stddev": ms.StdDev(),
"p75": ps[1], "variance": ms.Variance(),
"p95": ps[2], "p50": ps[0],
"p99": ps[3], "p75": ps[1],
"p999": ps[4], "p95": ps[2],
"p9999": ps[5], "p99": ps[3],
}, "p999": ps[4],
Time: now, "p9999": ps[5],
}) },
Time: now,
})
}
case metrics.Meter: case metrics.Meter:
ms := metric.Snapshot() ms := metric.Snapshot()
pts = append(pts, client.Point{ pts = append(pts, client.Point{

Loading…
Cancel
Save