Skip to content

Commit

Permalink
Make /metrics the only Prometheus metrics endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Stäber <[email protected]>
  • Loading branch information
fstab committed May 26, 2024
1 parent a764419 commit 34b3d38
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 34b3d38

Please sign in to comment.