Skip to main content

fedimint_wallet_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    IntGauge, register_histogram_vec_with_registry, register_int_gauge_with_registry,
8};
9use fedimint_metrics::{
10    AMOUNTS_BUCKETS_SATS, Histogram, HistogramVec, REGISTRY, histogram_opts, opts,
11    register_histogram_with_registry,
12};
13
14pub(crate) static WALLET_INOUT_SATS: LazyLock<HistogramVec> = LazyLock::new(|| {
15    register_histogram_vec_with_registry!(
16        histogram_opts!(
17            "wallet_inout_sats",
18            "Value of wallet input/out in sats",
19            AMOUNTS_BUCKETS_SATS.clone()
20        ),
21        &["direction"],
22        REGISTRY
23    )
24    .unwrap()
25});
26pub(crate) static WALLET_INOUT_FEES_SATS: LazyLock<HistogramVec> = LazyLock::new(|| {
27    register_histogram_vec_with_registry!(
28        histogram_opts!(
29            "wallet_inout_fees_sats",
30            "Value of wallet input/output fees in sats",
31            AMOUNTS_BUCKETS_SATS.clone()
32        ),
33        &["direction"],
34        REGISTRY
35    )
36    .unwrap()
37});
38pub(crate) static WALLET_PEGIN_SATS: LazyLock<Histogram> = LazyLock::new(|| {
39    register_histogram_with_registry!(
40        histogram_opts!(
41            "wallet_pegin_sats",
42            "Value of peg-in transactions in sats (deprecated - prefer wallet_inout_sats)",
43            AMOUNTS_BUCKETS_SATS.clone()
44        ),
45        REGISTRY
46    )
47    .unwrap()
48});
49pub(crate) static WALLET_PEGIN_FEES_SATS: LazyLock<Histogram> = LazyLock::new(|| {
50    register_histogram_with_registry!(
51        histogram_opts!(
52            "wallet_pegin_fees_sats",
53            "Value of peg-in fees in sats (deprecated - prefer wallet_inout_fees_sats)",
54            AMOUNTS_BUCKETS_SATS.clone()
55        ),
56        REGISTRY
57    )
58    .unwrap()
59});
60pub(crate) static WALLET_PEGOUT_SATS: LazyLock<Histogram> = LazyLock::new(|| {
61    register_histogram_with_registry!(
62        histogram_opts!(
63            "wallet_pegout_sats",
64            "Value of peg-out transactions in sats (deprecated - prefer wallet_inout_sats)",
65            AMOUNTS_BUCKETS_SATS.clone()
66        ),
67        REGISTRY
68    )
69    .unwrap()
70});
71pub(crate) static WALLET_PEGOUT_FEES_SATS: LazyLock<Histogram> = LazyLock::new(|| {
72    register_histogram_with_registry!(
73        histogram_opts!(
74            "wallet_pegout_fees_sats",
75            "Value of peg-out fees in sats (deprecated - prefer wallet_inout_fees_sats)",
76            AMOUNTS_BUCKETS_SATS.clone()
77        ),
78        REGISTRY
79    )
80    .unwrap()
81});
82pub(crate) static WALLET_BLOCK_COUNT: LazyLock<IntGauge> = LazyLock::new(|| {
83    register_int_gauge_with_registry!(
84        opts!(
85            "wallet_block_count",
86            "Blockchain block count as monitored by wallet module",
87        ),
88        REGISTRY
89    )
90    .unwrap()
91});