fedimint_gateway_server/
metrics.rs

1use std::sync::LazyLock;
2
3use fedimint_metrics::prometheus::{HistogramVec, register_histogram_vec_with_registry};
4use fedimint_metrics::{REGISTRY, histogram_opts};
5
6/// Histogram of HTLC handling durations in seconds
7pub static HTLC_HANDLING_DURATION_SECONDS: LazyLock<HistogramVec> = LazyLock::new(|| {
8    register_histogram_vec_with_registry!(
9        histogram_opts!(
10            "gateway_htlc_handling_duration_seconds",
11            "Duration of HTLC handling in the gateway",
12        ),
13        &["outcome"],
14        REGISTRY
15    )
16    .expect("metric registration should not fail")
17});
18
19/// Histogram of LNv2 HTLC handling attempt durations in seconds
20pub static HTLC_LNV2_ATTEMPT_DURATION_SECONDS: LazyLock<HistogramVec> = LazyLock::new(|| {
21    register_histogram_vec_with_registry!(
22        histogram_opts!(
23            "gateway_htlc_lnv2_attempt_duration_seconds",
24            "Duration of LNv2 HTLC handling attempts in the gateway",
25        ),
26        &["outcome"],
27        REGISTRY
28    )
29    .expect("metric registration should not fail")
30});
31
32/// Histogram of LNv1 HTLC handling attempt durations in seconds
33pub static HTLC_LNV1_ATTEMPT_DURATION_SECONDS: LazyLock<HistogramVec> = LazyLock::new(|| {
34    register_histogram_vec_with_registry!(
35        histogram_opts!(
36            "gateway_htlc_lnv1_attempt_duration_seconds",
37            "Duration of LNv1 HTLC handling attempts in the gateway",
38        ),
39        &["outcome"],
40        REGISTRY
41    )
42    .expect("metric registration should not fail")
43});