1use std::sync::Arc;
5
6pub trait Counter: Send + Sync + 'static {
8 fn inc(&self);
9 fn inc_by(&self, v: u64);
10 fn get(&self) -> u64;
11}
12
13pub trait Gauge: Send + Sync + 'static {
15 fn set(&self, v: i64);
16 fn inc(&self);
17 fn dec(&self);
18 fn get(&self) -> i64;
19}
20
21pub trait Histogram: Send + Sync + 'static {
23 fn observe(&self, v: f64);
24}
25
26pub trait CounterVec: Send + Sync + 'static {
28 fn with_labels(&self, labels: &[&str]) -> Arc<dyn Counter>;
29}
30
31pub trait GaugeVec: Send + Sync + 'static {
32 fn with_labels(&self, labels: &[&str]) -> Arc<dyn Gauge>;
33}
34
35pub trait HistogramVec: Send + Sync + 'static {
36 fn with_labels(&self, labels: &[&str]) -> Arc<dyn Histogram>;
37}
38
39pub trait MetricsRegistry: Send + Sync + 'static {
41 fn counter_vec(&self, name: &str, help: &str, label_keys: &[&str]) -> Arc<dyn CounterVec>;
42 fn gauge_vec(&self, name: &str, help: &str, label_keys: &[&str]) -> Arc<dyn GaugeVec>;
43 fn histogram_vec(&self, name: &str, help: &str, label_keys: &[&str]) -> Arc<dyn HistogramVec>;
44
45 fn render(&self) -> String;
47}