From 5ab791f51c3f8e354c73e3941b75f8c7f3520dfd Mon Sep 17 00:00:00 2001 From: dae won Date: Sat, 25 Jan 2025 23:07:48 +0900 Subject: [PATCH] Remove special handling of 404 and redirection statuses from Jetty client instrumentation See gh-5812 --- .../jetty12/client/JettyClientKeyValues.java | 21 ----------------- .../jetty12/client/JettyClientTags.java | 23 ------------------- .../client/JettyClientMetricsTest.java | 2 +- 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientKeyValues.java b/micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientKeyValues.java index fcd6d10e17..31579c5dc1 100644 --- a/micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientKeyValues.java +++ b/micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientKeyValues.java @@ -21,7 +21,6 @@ import io.micrometer.core.instrument.binder.http.Outcome; import org.eclipse.jetty.client.Request; import org.eclipse.jetty.client.Result; -import org.eclipse.jetty.http.HttpStatus; import java.util.function.BiFunction; import java.util.regex.Pattern; @@ -35,10 +34,6 @@ */ public final class JettyClientKeyValues { - private static final KeyValue URI_NOT_FOUND = KeyValue.of("uri", "NOT_FOUND"); - - private static final KeyValue URI_REDIRECTION = KeyValue.of("uri", "REDIRECTION"); - private static final KeyValue URI_ROOT = KeyValue.of("uri", "root"); private static final KeyValue EXCEPTION_NONE = KeyValue.of("exception", "None"); @@ -100,16 +95,6 @@ public static KeyValue status(@Nullable Result result) { */ public static KeyValue uri(Request request, @Nullable Result result, BiFunction successfulUriPattern) { - if (result != null && result.getResponse() != null) { - int status = result.getResponse().getStatus(); - if (HttpStatus.isRedirection(status)) { - return URI_REDIRECTION; - } - if (status == 404) { - return URI_NOT_FOUND; - } - } - String matchingPattern = successfulUriPattern.apply(request, result); matchingPattern = MULTIPLE_SLASH_PATTERN.matcher(matchingPattern).replaceAll("/"); if (matchingPattern.equals("/")) { @@ -133,12 +118,6 @@ public static KeyValue exception(@Nullable Result result) { if (exception == null) { return EXCEPTION_NONE; } - if (result.getResponse() != null) { - int status = result.getResponse().getStatus(); - if (status == 404 || HttpStatus.isRedirection(status)) { - return EXCEPTION_NONE; - } - } if (exception.getCause() != null) { exception = exception.getCause(); } diff --git a/micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientTags.java b/micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientTags.java index 6cf5ed7fc6..c03ab38380 100644 --- a/micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientTags.java +++ b/micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientTags.java @@ -19,9 +19,7 @@ import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.binder.http.Outcome; import org.eclipse.jetty.client.Request; -import org.eclipse.jetty.client.Response; import org.eclipse.jetty.client.Result; -import org.eclipse.jetty.http.HttpStatus; import java.util.function.Function; import java.util.regex.Pattern; @@ -35,10 +33,6 @@ */ public final class JettyClientTags { - private static final Tag URI_NOT_FOUND = Tag.of("uri", "NOT_FOUND"); - - private static final Tag URI_REDIRECTION = Tag.of("uri", "REDIRECTION"); - private static final Tag URI_ROOT = Tag.of("uri", "root"); private static final Tag EXCEPTION_NONE = Tag.of("exception", "None"); @@ -91,17 +85,6 @@ public static Tag status(Result result) { * @return the uri tag derived from the request result */ public static Tag uri(Result result, Function successfulUriPattern) { - Response response = result.getResponse(); - if (response != null) { - int status = response.getStatus(); - if (HttpStatus.isRedirection(status)) { - return URI_REDIRECTION; - } - if (status == 404) { - return URI_NOT_FOUND; - } - } - String matchingPattern = successfulUriPattern.apply(result); matchingPattern = MULTIPLE_SLASH_PATTERN.matcher(matchingPattern).replaceAll("/"); if (matchingPattern.equals("/")) { @@ -122,12 +105,6 @@ public static Tag exception(Result result) { if (exception == null) { return EXCEPTION_NONE; } - if (result.getResponse() != null) { - int status = result.getResponse().getStatus(); - if (status == 404 || HttpStatus.isRedirection(status)) { - return EXCEPTION_NONE; - } - } if (exception.getCause() != null) { exception = exception.getCause(); } diff --git a/micrometer-jetty12/src/test/java/io/micrometer/jetty12/client/JettyClientMetricsTest.java b/micrometer-jetty12/src/test/java/io/micrometer/jetty12/client/JettyClientMetricsTest.java index 18bd805d9e..a90b6e67f1 100644 --- a/micrometer-jetty12/src/test/java/io/micrometer/jetty12/client/JettyClientMetricsTest.java +++ b/micrometer-jetty12/src/test/java/io/micrometer/jetty12/client/JettyClientMetricsTest.java @@ -151,7 +151,7 @@ void notFound(WireMockRuntimeInfo wmRuntimeInfo) throws Exception { assertThat(registry.get("jetty.client.requests") .tag("outcome", "CLIENT_ERROR") .tag("status", "404") - .tag("uri", "NOT_FOUND") + .tag("uri", "/doesNotExist") .tag("host", "localhost") .timer() .count()).isEqualTo(1);