Skip to content

Commit

Permalink
Use the correct content type for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Nov 22, 2024
1 parent 5cefccc commit 0ceefbb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ui/src/server_axum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ async fn meta_gist_get(
.context(GistLoadingSnafu)
}

async fn metrics(_: MetricsAuthorization) -> Result<Vec<u8>, StatusCode> {
async fn metrics(_: MetricsAuthorization) -> Result<impl IntoResponse, StatusCode> {
use prometheus::{Encoder, TextEncoder};

let metric_families = prometheus::gather();
Expand All @@ -650,7 +650,15 @@ async fn metrics(_: MetricsAuthorization) -> Result<Vec<u8>, StatusCode> {

encoder
.encode(&metric_families, &mut buffer)
.map(|_| buffer)
.map(|_| {
(
[(
header::CONTENT_TYPE,
"text/plain; version=0.0.4; charset=utf-8",
)],
buffer,
)
})
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
}

Expand Down

0 comments on commit 0ceefbb

Please sign in to comment.