diff --git a/src/metrics.rs b/src/metrics.rs index 5f2e61a..92e114e 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -3,7 +3,7 @@ use std::io; use std::net::SocketAddr; use tiny_http; -pub use prometheus::{HistogramOpts, HistogramTimer, HistogramVec, IntCounter as Counter, +pub use prometheus::{GaugeVec, HistogramOpts, HistogramTimer, HistogramVec, IntCounter as Counter, IntGauge as Gauge, Opts as MetricOpts}; use util::spawn_thread; @@ -33,6 +33,12 @@ impl Metrics { g } + pub fn gauge_vec(&self, opts: prometheus::Opts, labels: &[&str]) -> GaugeVec { + let g = GaugeVec::new(opts, labels).unwrap(); + self.reg.register(Box::new(g.clone())).unwrap(); + g + } + pub fn histogram_vec(&self, opts: prometheus::HistogramOpts, labels: &[&str]) -> HistogramVec { let h = HistogramVec::new(opts, labels).unwrap(); self.reg.register(Box::new(h.clone())).unwrap();