From 34b3d38a3cebb81a895123e85f9c0254890f86d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20St=C3=A4ber?= Date: Sun, 26 May 2024 16:48:05 +0200 Subject: [PATCH] Make /metrics the only Prometheus metrics endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Stäber --- .../exporter/prometheus/PrometheusHttpServer.java | 2 -- .../exporter/prometheus/PrometheusHttpServerTest.java | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServer.java b/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServer.java index f815ea0ac54..8e5072d197d 100644 --- a/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServer.java +++ b/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServer.java @@ -17,7 +17,6 @@ import io.opentelemetry.sdk.metrics.export.CollectionRegistration; import io.opentelemetry.sdk.metrics.export.MetricReader; import io.prometheus.metrics.exporter.httpserver.HTTPServer; -import io.prometheus.metrics.exporter.httpserver.MetricsHandler; import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.IOException; import java.io.UncheckedIOException; @@ -84,7 +83,6 @@ public static PrometheusHttpServerBuilder builder() { .port(port) .executorService(executor) .registry(prometheusRegistry) - .defaultHandler(new MetricsHandler(prometheusRegistry)) .buildAndStart(); } catch (IOException e) { throw new UncheckedIOException("Could not create Prometheus HTTP server", e); diff --git a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerTest.java b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerTest.java index 449cc4c5c4c..0c91ab7ea72 100644 --- a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerTest.java +++ b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerTest.java @@ -229,7 +229,7 @@ void fetchOpenMetrics() { void fetchFiltered() { AggregatedHttpResponse response = client - .get("/?name[]=grpc_name_unit_total&name[]=bears_total&name[]=target_info") + .get("/metrics?name[]=grpc_name_unit_total&name[]=bears_total&name[]=target_info") .aggregate() .join(); assertThat(response.status()).isEqualTo(HttpStatus.OK); @@ -275,7 +275,7 @@ void fetchPrometheusCompressed() throws IOException { @SuppressWarnings("resource") @Test void fetchHead() { - AggregatedHttpResponse response = client.head("/").aggregate().join(); + AggregatedHttpResponse response = client.head("/metrics").aggregate().join(); assertThat(response.status()).isEqualTo(HttpStatus.OK); assertThat(response.headers().get(HttpHeaderNames.CONTENT_TYPE)) .isEqualTo("text/plain; version=0.0.4; charset=utf-8");