diff --git a/monitoring/micrometer-prometheus/src/main/java/io/quarkus/ts/micrometer/prometheus/PathPatternResource.java b/monitoring/micrometer-prometheus/src/main/java/io/quarkus/ts/micrometer/prometheus/PathPatternResource.java index b689d17263..68ed21faa5 100644 --- a/monitoring/micrometer-prometheus/src/main/java/io/quarkus/ts/micrometer/prometheus/PathPatternResource.java +++ b/monitoring/micrometer-prometheus/src/main/java/io/quarkus/ts/micrometer/prometheus/PathPatternResource.java @@ -23,6 +23,12 @@ public Response notFound() { return Response.status(Response.Status.NOT_FOUND).build(); //404 } + @GET + @Path("/not-found/{uri}") + public Response notFoundUri(@PathParam("uri") String uri) { + return Response.status(Response.Status.NOT_FOUND).build(); //404 + } + @GET @Path("/moved/{id}") public Response moved(@PathParam("id") String id) { diff --git a/monitoring/micrometer-prometheus/src/test/java/io/quarkus/ts/micrometer/prometheus/HttpPathMetricsPatternIT.java b/monitoring/micrometer-prometheus/src/test/java/io/quarkus/ts/micrometer/prometheus/HttpPathMetricsPatternIT.java index 5eaa0beb8e..7ad120759b 100644 --- a/monitoring/micrometer-prometheus/src/test/java/io/quarkus/ts/micrometer/prometheus/HttpPathMetricsPatternIT.java +++ b/monitoring/micrometer-prometheus/src/test/java/io/quarkus/ts/micrometer/prometheus/HttpPathMetricsPatternIT.java @@ -23,6 +23,7 @@ public class HttpPathMetricsPatternIT { private static final String HTTP_SERVER_REQUESTS_METRICS_FORMAT = "http_server_requests_seconds_%s{method=\"GET\",outcome=\"%s\",status=\"%d\",uri=\"%s\"}"; private static final String REDIRECT_ENDPOINT = "/test/redirect"; private static final String NOT_FOUND_ENDPOINT = "/test/not-found"; + private static final String NOT_FOUND_URI_ENDPOINT = "/test/not-found/{uri}"; private static final String MOVED_ENDPOINT = "/test/moved/{id}"; private static final String EMPTY_ENDPOINT = "/test"; @@ -31,15 +32,21 @@ public class HttpPathMetricsPatternIT { .withProperty("quarkus.management.enabled", "true"); @Test - public void verifyUriNotFoundInMetrics() { + public void verifyNotFoundInMetrics() { whenCallNotFoundEndpoint(); - thenMetricIsExposedInServiceEndpoint(404, "CLIENT_ERROR", NOT_FOUND_ENDPOINT); + thenMetricIsExposedInServiceEndpoint(404, "CLIENT_ERROR", "NOT_FOUND"); + } + + @Test + public void verifyUriNotFoundInMetrics() { + whenCallNotFoundWithParamEndpoint("/url123"); + thenMetricIsExposedInServiceEndpoint(404, "CLIENT_ERROR", NOT_FOUND_URI_ENDPOINT); } @Test public void verifyRedirectionInMetrtics() { whenCallRedirectEndpoint(); - thenMetricIsExposedInServiceEndpoint(302, "REDIRECTION", REDIRECT_ENDPOINT); + thenMetricIsExposedInServiceEndpoint(302, "REDIRECTION", "REDIRECTION"); } @Test @@ -74,6 +81,14 @@ private void whenCallNotFoundEndpoint() { .then().statusCode(HttpStatus.SC_NOT_FOUND); } + private void whenCallNotFoundWithParamEndpoint(String url) { + given() + .pathParam("uri", url) + .redirects().follow(false) + .when().get(NOT_FOUND_URI_ENDPOINT) + .then().statusCode(HttpStatus.SC_NOT_FOUND); + } + private void whenCallDynamicSegmentEndpoint(String id) { given() .pathParam("id", id)