lruttl/
metrics.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use prometheus::{IntCounterVec, IntGaugeVec};
use std::sync::LazyLock;

pub(crate) static CACHE_LOOKUP: LazyLock<IntCounterVec> = LazyLock::new(|| {
    prometheus::register_int_counter_vec!(
        "lruttl_lookup_count",
        "how many times a lruttl cache lookup was initiated for a given cache",
        &["cache_name"]
    )
    .unwrap()
});
pub(crate) static CACHE_EVICT: LazyLock<IntCounterVec> = LazyLock::new(|| {
    prometheus::register_int_counter_vec!(
        "lruttl_evict_count",
        "how many times a lruttl cache evicted an item due to capacity constraints",
        &["cache_name"]
    )
    .unwrap()
});
pub(crate) static CACHE_EXPIRE: LazyLock<IntCounterVec> = LazyLock::new(|| {
    prometheus::register_int_counter_vec!(
        "lruttl_expire_count",
        "how many times a lruttl cache removed an item due to ttl expiration",
        &["cache_name"]
    )
    .unwrap()
});
pub(crate) static CACHE_HIT: LazyLock<IntCounterVec> = LazyLock::new(|| {
    prometheus::register_int_counter_vec!(
        "lruttl_hit_count",
        "how many times a lruttl cache lookup was a hit for a given cache",
        &["cache_name"]
    )
    .unwrap()
});
pub(crate) static CACHE_MISS: LazyLock<IntCounterVec> = LazyLock::new(|| {
    prometheus::register_int_counter_vec!(
        "lruttl_miss_count",
        "how many times a lruttl cache lookup was a miss for a given cache",
        &["cache_name"]
    )
    .unwrap()
});
pub(crate) static CACHE_INSERT: LazyLock<IntCounterVec> = LazyLock::new(|| {
    prometheus::register_int_counter_vec!(
        "lruttl_insert_count",
        "how many times a lruttl cache was populated via unconditional insert",
        &["cache_name"]
    )
    .unwrap()
});
pub(crate) static CACHE_POPULATED: LazyLock<IntCounterVec> = LazyLock::new(|| {
    prometheus::register_int_counter_vec!(
        "lruttl_populated_count",
        "how many times a lruttl cache lookup resulted in performing the work to populate the entry",
        &["cache_name"]
    )
    .unwrap()
});
pub(crate) static CACHE_ERROR: LazyLock<IntCounterVec> = LazyLock::new(|| {
    prometheus::register_int_counter_vec!(
        "lruttl_error_count",
        "how many times a lruttl cache population resulted in an error",
        &["cache_name"]
    )
    .unwrap()
});
pub(crate) static CACHE_WAIT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
    prometheus::register_int_gauge_vec!(
        "lruttl_waiting_populate",
        "how many tasks are currently waiting for a cache entry to populate",
        &["cache_name"]
    )
    .unwrap()
});
pub(crate) static CACHE_SIZE: LazyLock<IntGaugeVec> = LazyLock::new(|| {
    prometheus::register_int_gauge_vec!(
        "lruttl_cache_size",
        "number of items contained in an lruttl cache",
        &["cache_name"]
    )
    .unwrap()
});