From d7ad76ea1e3c9bb9dd9ae46518563ab72e124df2 Mon Sep 17 00:00:00 2001 From: Tamo Date: Thu, 18 Sep 2025 17:04:13 +0200 Subject: [PATCH] improve the prometheus content type we return --- crates/meilisearch/src/routes/metrics.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/meilisearch/src/routes/metrics.rs b/crates/meilisearch/src/routes/metrics.rs index 1efd6d367..f57db5939 100644 --- a/crates/meilisearch/src/routes/metrics.rs +++ b/crates/meilisearch/src/routes/metrics.rs @@ -180,12 +180,6 @@ pub async fn get_metrics( let response = String::from_utf8(buffer).expect("Failed to convert bytes to string"); - // We cannot specify the version with ContentType(TEXT_PLAIN_UTF_8) so we have to write everything by hand :( - // see the following for what should be returned: https://prometheus.io/docs/instrumenting/content_negotiation/#content-type-response - let content_type = ("content-type", "text/plain; version=0.0.4; charset=utf-8"); - - Ok(HttpResponse::Ok() - // .insert_header(header::ContentType(mime::TEXT_PLAIN_UTF_8)) - .insert_header(content_type) - .body(response)) + let content_type = ("content-type", prometheus::TEXT_FORMAT); + Ok(HttpResponse::Ok().insert_header(content_type).body(response)) }