Skip to main content

fedimint_server_bitcoin_rpc/
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 server bitcoin RPC request durations in seconds, labeled by
9/// method and name
10pub static SERVER_BITCOIN_RPC_DURATION_SECONDS: LazyLock<HistogramVec> = LazyLock::new(|| {
11    register_histogram_vec_with_registry!(
12        histogram_opts!(
13            "server_bitcoin_rpc_request_duration_seconds",
14            "Duration of server bitcoin RPC requests",
15        ),
16        &["method", "name"],
17        REGISTRY
18    )
19    .expect("metric registration should not fail")
20});
21
22/// Counter of server bitcoin RPC requests, labeled by method, name, and result
23pub static SERVER_BITCOIN_RPC_REQUESTS_TOTAL: LazyLock<IntCounterVec> = LazyLock::new(|| {
24    register_int_counter_vec_with_registry!(
25        opts!(
26            "server_bitcoin_rpc_requests_total",
27            "Total number of server bitcoin RPC requests",
28        ),
29        &["method", "name", "result"],
30        REGISTRY
31    )
32    .expect("metric registration should not fail")
33});