risingwave_storage/monitor/
hummock_metrics.rsuse std::sync::LazyLock;
use prometheus::core::{AtomicU64, GenericCounter};
use prometheus::{
exponential_buckets, histogram_opts, register_histogram_with_registry,
register_int_counter_with_registry, Histogram, Registry,
};
use risingwave_common::monitor::GLOBAL_METRICS_REGISTRY;
#[derive(Debug, Clone)]
pub struct HummockMetrics {
pub get_new_sst_ids_counts: GenericCounter<AtomicU64>,
pub report_compaction_task_counts: GenericCounter<AtomicU64>,
pub get_new_sst_ids_latency: Histogram,
pub report_compaction_task_latency: Histogram,
}
pub static GLOBAL_HUMMOCK_METRICS: LazyLock<HummockMetrics> =
LazyLock::new(|| HummockMetrics::new(&GLOBAL_METRICS_REGISTRY));
impl HummockMetrics {
fn new(registry: &Registry) -> Self {
let get_new_sst_ids_counts = register_int_counter_with_registry!(
"state_store_get_new_sst_ids_counts",
"Total number of get_new_table_id requests that have been issued to state store",
registry
)
.unwrap();
let report_compaction_task_counts = register_int_counter_with_registry!(
"state_store_report_compaction_task_counts",
"Total number of report_compaction_task requests that have been issued to state store",
registry
)
.unwrap();
let time_buckets = exponential_buckets(0.01, 10.0, 7).unwrap();
let get_new_sst_ids_latency_opts = histogram_opts!(
"state_store_get_new_sst_ids_latency",
"Total latency of get new table id that have been issued to state store",
time_buckets.clone()
);
let get_new_sst_ids_latency =
register_histogram_with_registry!(get_new_sst_ids_latency_opts, registry).unwrap();
let report_compaction_task_latency_opts = histogram_opts!(
"state_store_report_compaction_task_latency",
"Total latency of report compaction task that have been issued to state store",
time_buckets
);
let report_compaction_task_latency =
register_histogram_with_registry!(report_compaction_task_latency_opts, registry)
.unwrap();
Self {
get_new_sst_ids_counts,
report_compaction_task_counts,
get_new_sst_ids_latency,
report_compaction_task_latency,
}
}
pub fn unused() -> Self {
GLOBAL_HUMMOCK_METRICS.clone()
}
}