starknet_devnet_server/
metrics.rs1#![allow(clippy::expect_used)]
2use lazy_static::lazy_static;
3use prometheus::{HistogramVec, IntCounterVec, Opts, Registry};
4
5lazy_static! {
6 pub static ref RPC_CALL_DURATION: HistogramVec = HistogramVec::new(
8 prometheus::HistogramOpts::new(
9 "rpc_call_duration_seconds",
10 "Duration of RPC calls in seconds"
11 )
12 .buckets(vec![
13 0.00005, 0.0001, 0.00025, 0.0005, 0.001, 0.0025, 0.005, 0.01, 0.015, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0
14 ]),
15 &["method"]
16 )
17 .expect("Failed to create RPC_CALL_DURATION histogram");
18
19 pub static ref RPC_CALL_COUNT: IntCounterVec = IntCounterVec::new(
21 Opts::new("rpc_call_count", "Total number of RPC calls"),
22 &["method", "status"]
23 )
24 .expect("Failed to create RPC_CALL_COUNT counter");
25}
26
27pub fn register_metrics(registry: &Registry) -> Result<(), prometheus::Error> {
29 registry.register(Box::new(RPC_CALL_DURATION.clone()))?;
30 registry.register(Box::new(RPC_CALL_COUNT.clone()))?;
31 Ok(())
32}