fedimint_wallet_server/
metrics.rs

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