mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-05 20:26:31 +00:00
send the version when returning prometheus metrics
This commit is contained in:
@ -8,6 +8,7 @@ use meilisearch_types::keys::actions;
|
|||||||
use meilisearch_types::tasks::Status;
|
use meilisearch_types::tasks::Status;
|
||||||
use prometheus::{Encoder, TextEncoder};
|
use prometheus::{Encoder, TextEncoder};
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
use tracing::Instrument;
|
||||||
use utoipa::OpenApi;
|
use utoipa::OpenApi;
|
||||||
|
|
||||||
use crate::extractors::authentication::policies::ActionPolicy;
|
use crate::extractors::authentication::policies::ActionPolicy;
|
||||||
@ -181,5 +182,12 @@ pub async fn get_metrics(
|
|||||||
|
|
||||||
let response = String::from_utf8(buffer).expect("Failed to convert bytes to string");
|
let response = String::from_utf8(buffer).expect("Failed to convert bytes to string");
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().insert_header(header::ContentType(mime::TEXT_PLAIN)).body(response))
|
// 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))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user