fedimint_connectors/
metrics.rs

1use std::sync::LazyLock;
2
3use fedimint_metrics::prometheus::{
4    HistogramVec, IntCounterVec, register_histogram_vec_with_registry,
5};
6use fedimint_metrics::{REGISTRY, histogram_opts, opts, register_int_counter_vec_with_registry};
7
8/// Histogram of connection durations in seconds, labeled by scheme
9/// (ws/wss/iroh/http/https)
10pub static CONNECTION_DURATION_SECONDS: LazyLock<HistogramVec> = LazyLock::new(|| {
11    register_histogram_vec_with_registry!(
12        histogram_opts!(
13            "connector_connection_duration_seconds",
14            "Duration of establishing connections to federation peers",
15        ),
16        &["scheme"],
17        REGISTRY
18    )
19    .expect("metric registration should not fail")
20});
21
22/// Counter of connection attempts, labeled by scheme and result
23pub static CONNECTION_ATTEMPTS_TOTAL: LazyLock<IntCounterVec> = LazyLock::new(|| {
24    register_int_counter_vec_with_registry!(
25        opts!(
26            "connector_connection_attempts_total",
27            "Total number of connection attempts to federation peers",
28        ),
29        &["scheme", "result"],
30        REGISTRY
31    )
32    .expect("metric registration should not fail")
33});