Skip to content

Commit

Permalink
Use the correct content-type for metrics (#951)
Browse files Browse the repository at this point in the history
Use the correct content type for metrics

Signed-off-by: Jakub Scholz <[email protected]>
  • Loading branch information
scholzj authored Dec 5, 2024
1 parent 150bbd0 commit c11ffd0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/io/strimzi/kafka/bridge/http/HttpBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,10 @@ private String openapiFileName(RoutingContext routingContext) {
}

private void metrics(RoutingContext routingContext) {
routingContext.response().setStatusCode(HttpResponseStatus.OK.code()).end(metricsReporter.scrape());
routingContext.response()
.putHeader("Content-Type", "text/plain; version=0.0.4; charset=utf-8")
.setStatusCode(HttpResponseStatus.OK.code())
.end(metricsReporter.scrape());
}

private void information(RoutingContext routingContext) {
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/io/strimzi/kafka/bridge/http/OtherServicesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ void healthyTest(VertxTestContext context) throws InterruptedException {
}
}

@Test
void metricsTest(VertxTestContext context) {
baseService()
.getRequest("/metrics")
.send(ar -> {
context.verify(() -> {
assertThat(ar.succeeded(), is(true));
assertThat(ar.result().statusCode(), is(HttpResponseStatus.OK.code()));
assertThat(ar.result().getHeader("Content-Type"), is("text/plain; version=0.0.4; charset=utf-8"));
context.completeNow();
});
});
}

@Test
void openapiv2Test(VertxTestContext context) {
baseService()
Expand Down

0 comments on commit c11ffd0

Please sign in to comment.