cat_gateway/metrics/
endpoint.rs1use std::sync::LazyLock;
4
5use prometheus::{register_histogram_vec, register_int_counter_vec, HistogramVec, IntCounterVec};
6
7const METRIC_LABELS: [&str; 3] = ["endpoint", "method", "status_code"];
9const CLIENT_METRIC_LABELS: [&str; 2] = ["client", "status_code"];
11
12pub(crate) static HTTP_REQ_DURATION_MS: LazyLock<HistogramVec> = LazyLock::new(|| {
16 register_histogram_vec!(
17 "http_request_duration_ms",
18 "Duration of HTTP requests in milliseconds",
19 &METRIC_LABELS
20 )
21 .unwrap()
22});
23
24pub(crate) static HTTP_REQ_CPU_TIME_MS: LazyLock<HistogramVec> = LazyLock::new(|| {
26 register_histogram_vec!(
27 "http_request_cpu_time_ms",
28 "CPU Time of HTTP requests in milliseconds",
29 &METRIC_LABELS
30 )
31 .unwrap()
32});
33
34pub(crate) static HTTP_REQUEST_COUNT: LazyLock<IntCounterVec> = LazyLock::new(|| {
44 register_int_counter_vec!(
45 "http_request_count",
46 "Number of HTTP requests",
47 &METRIC_LABELS
48 )
49 .unwrap()
50});
51
52pub(crate) static CLIENT_REQUEST_COUNT: LazyLock<IntCounterVec> = LazyLock::new(|| {
54 register_int_counter_vec!(
55 "client_request_count",
56 "Number of HTTP requests per client",
57 &CLIENT_METRIC_LABELS
58 )
59 .unwrap()
60});