From 86984e3236ef4771d964f6ac36b226717845f561 Mon Sep 17 00:00:00 2001 From: OlivierDehaene Date: Tue, 17 Sep 2024 18:01:28 +0200 Subject: [PATCH] fix: metrics unbounded memory (#2528) --- router/src/server.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/router/src/server.rs b/router/src/server.rs index 8bd49b93..9cec2aaa 100644 --- a/router/src/server.rs +++ b/router/src/server.rs @@ -2136,9 +2136,12 @@ async fn start( .unwrap(); // .set_buckets_for_metric(skipped_matcher, &skipped_buckets) // .unwrap(); - let prom_handle = builder - .install_recorder() - .expect("failed to install metrics recorder"); + // See: https://github.com/metrics-rs/metrics/issues/467#issuecomment-2022755151 + let (recorder, _) = builder + .build() + .expect("failed to build prometheus recorder"); + let prom_handle = recorder.handle(); + metrics::set_global_recorder(recorder).expect("Failed to set global recorder"); // Metrics descriptions metrics::describe_counter!("tgi_request_success", "Number of successful requests");