1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Support simple histogram metric

This commit is contained in:
Roman Zeyde 2018-06-25 13:07:07 +03:00
parent 712c86d405
commit 841a800505
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -3,8 +3,8 @@ use std::io;
use std::net::SocketAddr;
use tiny_http;
pub use prometheus::{GaugeVec, HistogramOpts, HistogramTimer, HistogramVec, IntCounter as Counter,
IntGauge as Gauge, Opts as MetricOpts};
pub use prometheus::{GaugeVec, Histogram, HistogramOpts, HistogramTimer, HistogramVec,
IntCounter as Counter, IntGauge as Gauge, Opts as MetricOpts};
use util::spawn_thread;
@ -39,6 +39,12 @@ impl Metrics {
g
}
pub fn histogram(&self, opts: prometheus::HistogramOpts) -> Histogram {
let h = Histogram::with_opts(opts).unwrap();
self.reg.register(Box::new(h.clone())).unwrap();
h
}
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();