From dbd44bbfe6f81df8211a470f800a17b97dd5177b Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 7 Feb 2023 17:50:44 +0200 Subject: [PATCH] Return text from /q/metrics when the Accept header contains html This makes the endpoint more friendly for browsers See: https://quarkusio.zulipchat.com/#narrow/stream/187030-users --- .../micrometer/runtime/export/handlers/PrometheusHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/handlers/PrometheusHandler.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/handlers/PrometheusHandler.java index 1b4ab7517339c..9fac4989b2a0d 100644 --- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/handlers/PrometheusHandler.java +++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/handlers/PrometheusHandler.java @@ -52,7 +52,7 @@ private String chooseContentType(String acceptHeader) { if (acceptHeader == null) { return TextFormat.CONTENT_TYPE_OPENMETRICS_100; } - if (acceptHeader.startsWith("text/plain")) { + if (acceptHeader.contains("text/plain") || acceptHeader.contains("text/html")) { return TextFormat.CONTENT_TYPE_004; } return TextFormat.CONTENT_TYPE_OPENMETRICS_100;