cnidarium/metrics.rs
1#![cfg(feature = "metrics")]
2//! Crate-specific metrics functionality.
3//!
4//! This module re-exports the contents of the `metrics` crate. This is
5//! effectively a way to monkey-patch the functions in this module into the
6//! `metrics` crate, at least from the point of view of the other code in this
7//! crate.
8//!
9//! Code in this crate that wants to use metrics should `use crate::metrics;`,
10//! so that this module shadows the `metrics` crate.
11//!
12//! This trick is probably good to avoid in general, because it could be
13//! confusing, but in this limited case, it seems like a clean option.
14
15pub use metrics::*;
16
17/// Registers all metrics used by this crate.
18pub fn register_metrics() {
19 describe_histogram!(
20 STORAGE_GET_RAW_DURATION,
21 Unit::Seconds,
22 "The duration of a get_raw request"
23 );
24 describe_histogram!(
25 STORAGE_NONCONSENSUS_GET_RAW_DURATION,
26 Unit::Seconds,
27 "The duration of a nonverifiable_get_raw request"
28 );
29}
30
31pub const STORAGE_GET_RAW_DURATION: &str = "cnidarium_get_raw_duration_seconds";
32pub const STORAGE_NONCONSENSUS_GET_RAW_DURATION: &str =
33 "cnidarium_nonverifiable_get_raw_duration_seconds";