From 1b601f70c671969a0db05eee65e4c911b9d91716 Mon Sep 17 00:00:00 2001 From: Tamo Date: Thu, 25 May 2023 11:08:16 +0200 Subject: [PATCH] increase the bucketing of requests --- meilisearch/src/metrics.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/meilisearch/src/metrics.rs b/meilisearch/src/metrics.rs index c518db941..7ee5241db 100644 --- a/meilisearch/src/metrics.rs +++ b/meilisearch/src/metrics.rs @@ -5,18 +5,18 @@ use prometheus::{ }; /// Create evenly distributed buckets -fn create_buckets() -> [f64; N] { - let mut array = [0.0; N]; - - for i in 0..N { - array[i] = ((i + 1) as f64) / N as f64; - } - - array +fn create_buckets() -> [f64; 29] { + (0..10) + .chain((10..100).step_by(10)) + .chain((100..=1000).step_by(100)) + .map(|i| i as f64 / 1000.) + .collect::>() + .try_into() + .unwrap() } 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!( opts!("http_requests_total", "HTTP requests total"), &["method", "path"]