increase the bucketing of requests

This commit is contained in:
Tamo 2023-05-25 11:08:16 +02:00
parent 57d53de402
commit 1b601f70c6

View File

@ -5,18 +5,18 @@ use prometheus::{
}; };
/// Create evenly distributed buckets /// Create evenly distributed buckets
fn create_buckets<const N: usize>() -> [f64; N] { fn create_buckets() -> [f64; 29] {
let mut array = [0.0; N]; (0..10)
.chain((10..100).step_by(10))
for i in 0..N { .chain((100..=1000).step_by(100))
array[i] = ((i + 1) as f64) / N as f64; .map(|i| i as f64 / 1000.)
} .collect::<Vec<_>>()
.try_into()
array .unwrap()
} }
lazy_static! { lazy_static! {
pub static ref HTTP_RESPONSE_TIME_CUSTOM_BUCKETS: [f64; 100] = create_buckets(); pub static ref HTTP_RESPONSE_TIME_CUSTOM_BUCKETS: [f64; 29] = create_buckets();
pub static ref HTTP_REQUESTS_TOTAL: IntCounterVec = register_int_counter_vec!( pub static ref HTTP_REQUESTS_TOTAL: IntCounterVec = register_int_counter_vec!(
opts!("http_requests_total", "HTTP requests total"), opts!("http_requests_total", "HTTP requests total"),
&["method", "path"] &["method", "path"]