lruttl/
metrics.rs

1use kumo_prometheus::declare_metric;
2
3macro_rules! extra {
4    () => {
5        " The `cache_name` label identifies which cache.  See [kumo.set_lruttl_cache_capacity](../../kumo/set_lruttl_cache_capacity.md) for a list of caches."
6    }
7}
8
9declare_metric! {
10/// How many times a lruttl cache lookup was initiated for a given cache.
11///
12#[doc = extra!()]
13pub(crate) static CACHE_LOOKUP: IntCounterVec(
14        "lruttl_lookup_count",
15        &["cache_name"]);
16}
17
18declare_metric! {
19/// how many times a lruttl cache evicted an item due to capacity constraints
20///
21#[doc = extra!()]
22pub(crate) static CACHE_EVICT: IntCounterVec(
23        "lruttl_evict_count",
24        &["cache_name"]);
25}
26
27declare_metric! {
28/// how many times a lruttl cache removed an item due to ttl expiration
29///
30#[doc = extra!()]
31pub(crate) static CACHE_EXPIRE: IntCounterVec(
32        "lruttl_expire_count",
33        &["cache_name"]);
34}
35
36declare_metric! {
37/// how many times a lruttl cache lookup was a hit for a given cache
38///
39#[doc = extra!()]
40pub(crate) static CACHE_HIT: IntCounterVec(
41        "lruttl_hit_count",
42        &["cache_name"]);
43}
44
45declare_metric! {
46/// how many times a lruttl cache lookup was a miss for a given cache
47///
48#[doc = extra!()]
49pub(crate) static CACHE_MISS: IntCounterVec(
50        "lruttl_miss_count",
51        &["cache_name"]);
52}
53
54declare_metric! {
55/// how many times a lruttl cache was populated via unconditional insert
56///
57#[doc = extra!()]
58pub(crate) static CACHE_INSERT: IntCounterVec(
59        "lruttl_insert_count",
60        &["cache_name"]);
61}
62
63declare_metric! {
64/// how many times a lruttl cache lookup resulted in performing the work to populate the entry
65///
66#[doc = extra!()]
67pub(crate) static CACHE_POPULATED: IntCounterVec(
68        "lruttl_populated_count",
69        &["cache_name"]);
70}
71
72declare_metric! {
73/// how many times a lruttl cache population resulted in an error
74///
75#[doc = extra!()]
76pub(crate) static CACHE_ERROR: IntCounterVec(
77        "lruttl_error_count",
78        &["cache_name"]);
79}
80
81declare_metric! {
82/// how many times a lruttl cache population was satisfied by a stale value
83///
84#[doc = extra!()]
85pub(crate) static CACHE_STALE: IntCounterVec(
86        "lruttl_stale_count",
87        &["cache_name"]);
88}
89
90declare_metric! {
91/// how many tasks are currently waiting for a cache entry to populate
92///
93#[doc = extra!()]
94pub(crate) static CACHE_WAIT: IntGaugeVec(
95        "lruttl_waiting_populate",
96        &["cache_name"]);
97}
98
99declare_metric! {
100/// The number of items currently contained in an lruttl cache.
101///
102#[doc = extra!()]
103pub(crate) static CACHE_SIZE: IntGaugeVec(
104        "lruttl_cache_size",
105        &["cache_name"]);
106}