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