1use std::sync::LazyLock;
5
6#[doc(hidden)]
8pub use linera_base::prometheus_util::{self, exponential_bucket_latencies};
9use prometheus::IntCounterVec;
10
11pub fn increment_counter(counter: &LazyLock<IntCounterVec>, struct_name: &str, base_key: &[u8]) {
13 let base_key = hex::encode(base_key);
14 let labels = [struct_name, &base_key];
15 counter.with_label_values(&labels).inc();
16}
17
18#[doc(hidden)]
20pub static LOAD_VIEW_LATENCY: LazyLock<prometheus::HistogramVec> = LazyLock::new(|| {
21 prometheus_util::register_histogram_vec(
22 "load_view_latency",
23 "Load view latency",
24 &[],
25 exponential_bucket_latencies(10.0),
26 )
27});
28
29#[doc(hidden)]
31pub static LOAD_VIEW_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
32 prometheus_util::register_int_counter_vec(
33 "load_view",
34 "The metric counting how often a view is read from storage",
35 &["type", "base_key"],
36 )
37});
38#[doc(hidden)]
40pub static SAVE_VIEW_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
41 prometheus_util::register_int_counter_vec(
42 "save_view",
43 "The metric counting how often a view is written from storage",
44 &["type", "base_key"],
45 )
46});