Skip to content

Commit

Permalink
Merge pull request #1122 from rust-lang/prom-content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster authored Nov 22, 2024
2 parents 5cefccc + 0ceefbb commit 27f0be5
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 27f0be5

Please sign in to comment.