2021-05-22 19:10:03 -07:00
|
|
|
use once_cell::sync::Lazy;
|
|
|
|
use prometheus::{register_int_counter, IntCounter};
|
|
|
|
|
2021-05-23 16:05:57 -07:00
|
|
|
macro_rules! init_counters {
|
|
|
|
($(($counter:ident, $ty:ty, $name:literal, $desc:literal),)*) => {
|
|
|
|
$(
|
|
|
|
pub static $counter: Lazy<$ty> = Lazy::new(|| {
|
|
|
|
register_int_counter!($name, $desc).unwrap()
|
|
|
|
});
|
|
|
|
)*
|
2021-05-22 19:10:03 -07:00
|
|
|
|
2021-05-23 16:05:57 -07:00
|
|
|
#[allow(clippy::shadow_unrelated)]
|
|
|
|
pub fn init() {
|
|
|
|
$(let _a = $counter.get();)*
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2021-05-22 19:10:03 -07:00
|
|
|
|
2021-05-23 16:05:57 -07:00
|
|
|
init_counters!(
|
|
|
|
(
|
|
|
|
CACHE_HIT_COUNTER,
|
|
|
|
IntCounter,
|
2021-07-14 23:13:31 -07:00
|
|
|
"cache_hit_total",
|
2021-05-23 16:05:57 -07:00
|
|
|
"The number of cache hits."
|
|
|
|
),
|
|
|
|
(
|
|
|
|
CACHE_MISS_COUNTER,
|
|
|
|
IntCounter,
|
2021-07-14 23:13:31 -07:00
|
|
|
"cache_miss_total",
|
2021-05-23 16:05:57 -07:00
|
|
|
"The number of cache misses."
|
|
|
|
),
|
|
|
|
(
|
|
|
|
REQUESTS_TOTAL_COUNTER,
|
|
|
|
IntCounter,
|
|
|
|
"requests_total",
|
|
|
|
"The total number of requests served."
|
|
|
|
),
|
|
|
|
(
|
|
|
|
REQUESTS_DATA_COUNTER,
|
|
|
|
IntCounter,
|
2021-07-14 23:13:31 -07:00
|
|
|
"requests_data_total",
|
2021-05-22 19:10:03 -07:00
|
|
|
"The number of requests served from the /data endpoint."
|
2021-05-23 16:05:57 -07:00
|
|
|
),
|
|
|
|
(
|
|
|
|
REQUESTS_DATA_SAVER_COUNTER,
|
|
|
|
IntCounter,
|
2021-07-14 23:13:31 -07:00
|
|
|
"requests_data_saver_total",
|
2021-05-22 19:10:03 -07:00
|
|
|
"The number of requests served from the /data-saver endpoint."
|
2021-05-23 16:05:57 -07:00
|
|
|
),
|
|
|
|
(
|
|
|
|
REQUESTS_OTHER_COUNTER,
|
|
|
|
IntCounter,
|
2021-07-14 23:13:31 -07:00
|
|
|
"requests_other_total",
|
2021-05-22 19:10:03 -07:00
|
|
|
"The total number of request not served by primary endpoints."
|
2021-05-23 16:05:57 -07:00
|
|
|
),
|
|
|
|
);
|