Add Metrics::gauge_vec() method

This commit is contained in:
Roman Zeyde 2018-06-14 15:58:35 +03:00
parent 5a580e1a27
commit 3d77353d78
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -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();