Support vectorized counter metric

This commit is contained in:
Roman Zeyde 2018-06-25 13:22:30 +03:00
parent 2cf765ba5c
commit ec844fe876
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -4,7 +4,8 @@ use std::net::SocketAddr;
use tiny_http;
pub use prometheus::{GaugeVec, Histogram, HistogramOpts, HistogramTimer, HistogramVec,
IntCounter as Counter, IntGauge as Gauge, Opts as MetricOpts};
IntCounter as Counter, IntCounterVec as CounterVec, IntGauge as Gauge,
Opts as MetricOpts};
use util::spawn_thread;
@ -27,6 +28,12 @@ impl Metrics {
c
}
pub fn counter_vec(&self, opts: prometheus::Opts, labels: &[&str]) -> CounterVec {
let c = CounterVec::new(opts, labels).unwrap();
self.reg.register(Box::new(c.clone())).unwrap();
c
}
pub fn gauge(&self, opts: prometheus::Opts) -> Gauge {
let g = Gauge::with_opts(opts).unwrap();
self.reg.register(Box::new(g.clone())).unwrap();