#[cfg(feature = "metrics")]
use lazy_static::lazy_static;
#[cfg(feature = "metrics")]
lazy_static! {
pub static ref MOKA_ENTRIES: &'static str = {
metrics::describe_gauge!(
"hitbox_moka_entries",
"Current number of entries in the Moka cache."
);
"hitbox_moka_entries"
};
pub static ref MOKA_SIZE_BYTES: &'static str = {
metrics::describe_gauge!(
"hitbox_moka_size_bytes",
"Current weighted size of the Moka cache in bytes."
);
"hitbox_moka_size_bytes"
};
}
#[cfg(feature = "metrics")]
#[inline]
pub fn record_capacity(backend: &str, entries: u64, size_bytes: u64) {
metrics::gauge!(*MOKA_ENTRIES, "backend" => backend.to_string()).set(entries as f64);
metrics::gauge!(*MOKA_SIZE_BYTES, "backend" => backend.to_string()).set(size_bytes as f64);
}
#[cfg(not(feature = "metrics"))]
#[inline]
pub fn record_capacity(_backend: &str, _entries: u64, _size_bytes: u64) {}