risingwave_common_metrics/
metrics.rs1use prometheus::core::{AtomicU64, GenericGaugeVec};
16
17pub type UintGaugeVec = GenericGaugeVec<AtomicU64>;
18
19#[macro_export]
20macro_rules! register_gauge_vec {
21 ($TYPE:ident, $OPTS:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{
22 let gauge_vec = $TYPE::new($OPTS, $LABELS_NAMES).unwrap();
23 $REGISTRY
24 .register(Box::new(gauge_vec.clone()))
25 .map(|_| gauge_vec)
26 }};
27}
28
29#[macro_export]
30macro_rules! register_uint_gauge_vec_with_registry {
31 ($OPTS:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{
32 use $crate::UintGaugeVec;
33 $crate::register_gauge_vec!(UintGaugeVec, $OPTS, $LABELS_NAMES, $REGISTRY)
34 }};
35
36 ($NAME:expr, $HELP:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{
37 register_uint_gauge_vec_with_registry!(
38 prometheus::opts!($NAME, $HELP),
39 $LABELS_NAMES,
40 $REGISTRY
41 )
42 }};
43}