Skip to content

Commit

Permalink
Add Content-Type HTTP header to metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Nov 15, 2024
1 parent d0dd634 commit 6f396e2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion shared/subspace-metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ async fn metrics(registry: Data<RegistryAdapter>) -> Result<HttpResponse, Box<dy
}
}

let resp = HttpResponse::build(StatusCode::OK).body(encoded_metrics);
let resp = HttpResponse::build(StatusCode::OK)
.content_type("application/openmetrics-text; version=1.0.0; charset=utf-8")
.body(encoded_metrics);

Ok(resp)
}
Expand Down

2 comments on commit 6f396e2

@Waterman1997
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change caused me some trouble. Although it seems that exposing the OpenMetrics endpoint is more standardized, when I directly access the endpoint with a browser, the file is downloaded instead of displayed directly, and debugging indicators is not as convenient as before.😢

@nazar-pc
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you expected, you're not supposed to open it in the browser anyway and if you want to take a look at it downloading in CLI with curl or something like that is trivial. We're not going to change it to non-standard content type anyway.

Please sign in to comment.