Map counters to metrics
This commit is contained in:
parent
3b1aa846b5
commit
0ee86ff313
|
@ -1,3 +1,5 @@
|
|||
use influx_db_client as influxdb;
|
||||
use metrics;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::time::Duration;
|
||||
use timing;
|
||||
|
@ -45,6 +47,15 @@ impl Counter {
|
|||
timing::timestamp(),
|
||||
);
|
||||
}
|
||||
metrics::submit(
|
||||
influxdb::Point::new(&format!("counter_{}", self.name))
|
||||
.add_field("count", influxdb::Value::Integer(events as i64))
|
||||
.add_field(
|
||||
"duration_ms",
|
||||
influxdb::Value::Integer(timing::duration_as_ms(&dur) as i64),
|
||||
)
|
||||
.to_owned(),
|
||||
);
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -56,6 +56,7 @@ impl InfluxDbMetricsWriter {
|
|||
impl MetricsWriter for InfluxDbMetricsWriter {
|
||||
fn write(&self, points: Vec<influxdb::Point>) {
|
||||
if let Some(ref client) = self.client {
|
||||
info!("submitting {} points", points.len());
|
||||
if let Err(err) = client.write_points(
|
||||
influxdb::Points { point: points },
|
||||
Some(influxdb::Precision::Milliseconds),
|
||||
|
|
Loading…
Reference in New Issue