Skip to main content

fedimint_ln_server/
metrics.rs

1#![allow(clippy::disallowed_types)]
2// Prometheus registration macros use `HashMap` internally.
3
4use std::sync::LazyLock;
5
6use fedimint_metrics::prometheus::{
7    register_histogram_vec_with_registry, register_int_counter_with_registry,
8};
9use fedimint_metrics::{
10    AMOUNTS_BUCKETS_SATS, HistogramVec, IntCounter, REGISTRY, histogram_opts, opts,
11};
12
13pub static LN_INCOMING_OFFER: LazyLock<IntCounter> = LazyLock::new(|| {
14    register_int_counter_with_registry!(
15        opts!("ln_incoming_offer_total", "Incoming payment offer"),
16        REGISTRY
17    )
18    .unwrap()
19});
20pub static LN_CANCEL_OUTGOING_CONTRACTS: LazyLock<IntCounter> = LazyLock::new(|| {
21    register_int_counter_with_registry!(
22        opts!(
23            "ln_canceled_outgoing_contract_total",
24            "Canceled outgoing contract"
25        ),
26        REGISTRY
27    )
28    .unwrap()
29});
30pub static LN_FUNDED_CONTRACT_SATS: LazyLock<HistogramVec> = LazyLock::new(|| {
31    register_histogram_vec_with_registry!(
32        histogram_opts!(
33            "ln_funded_contract_sats",
34            "Funded (with outgoing or incoming direction) contract amount in sats",
35            AMOUNTS_BUCKETS_SATS.clone()
36        ),
37        &["direction"],
38        REGISTRY
39    )
40    .unwrap()
41});