Skip to content

Commit 5ab791f

Browse files
committed
Remove special handling of 404 and redirection statuses from Jetty client instrumentation
See gh-5812
1 parent c39bda3 commit 5ab791f

File tree

3 files changed

+1
-45
lines changed

3 files changed

+1
-45
lines changed

micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientKeyValues.java

-21
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import io.micrometer.core.instrument.binder.http.Outcome;
2222
import org.eclipse.jetty.client.Request;
2323
import org.eclipse.jetty.client.Result;
24-
import org.eclipse.jetty.http.HttpStatus;
2524

2625
import java.util.function.BiFunction;
2726
import java.util.regex.Pattern;
@@ -35,10 +34,6 @@
3534
*/
3635
public final class JettyClientKeyValues {
3736

38-
private static final KeyValue URI_NOT_FOUND = KeyValue.of("uri", "NOT_FOUND");
39-
40-
private static final KeyValue URI_REDIRECTION = KeyValue.of("uri", "REDIRECTION");
41-
4237
private static final KeyValue URI_ROOT = KeyValue.of("uri", "root");
4338

4439
private static final KeyValue EXCEPTION_NONE = KeyValue.of("exception", "None");
@@ -100,16 +95,6 @@ public static KeyValue status(@Nullable Result result) {
10095
*/
10196
public static KeyValue uri(Request request, @Nullable Result result,
10297
BiFunction<Request, Result, String> successfulUriPattern) {
103-
if (result != null && result.getResponse() != null) {
104-
int status = result.getResponse().getStatus();
105-
if (HttpStatus.isRedirection(status)) {
106-
return URI_REDIRECTION;
107-
}
108-
if (status == 404) {
109-
return URI_NOT_FOUND;
110-
}
111-
}
112-
11398
String matchingPattern = successfulUriPattern.apply(request, result);
11499
matchingPattern = MULTIPLE_SLASH_PATTERN.matcher(matchingPattern).replaceAll("/");
115100
if (matchingPattern.equals("/")) {
@@ -133,12 +118,6 @@ public static KeyValue exception(@Nullable Result result) {
133118
if (exception == null) {
134119
return EXCEPTION_NONE;
135120
}
136-
if (result.getResponse() != null) {
137-
int status = result.getResponse().getStatus();
138-
if (status == 404 || HttpStatus.isRedirection(status)) {
139-
return EXCEPTION_NONE;
140-
}
141-
}
142121
if (exception.getCause() != null) {
143122
exception = exception.getCause();
144123
}

micrometer-jetty12/src/main/java/io/micrometer/jetty12/client/JettyClientTags.java

-23
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
import io.micrometer.core.instrument.Tag;
2020
import io.micrometer.core.instrument.binder.http.Outcome;
2121
import org.eclipse.jetty.client.Request;
22-
import org.eclipse.jetty.client.Response;
2322
import org.eclipse.jetty.client.Result;
24-
import org.eclipse.jetty.http.HttpStatus;
2523

2624
import java.util.function.Function;
2725
import java.util.regex.Pattern;
@@ -35,10 +33,6 @@
3533
*/
3634
public final class JettyClientTags {
3735

38-
private static final Tag URI_NOT_FOUND = Tag.of("uri", "NOT_FOUND");
39-
40-
private static final Tag URI_REDIRECTION = Tag.of("uri", "REDIRECTION");
41-
4236
private static final Tag URI_ROOT = Tag.of("uri", "root");
4337

4438
private static final Tag EXCEPTION_NONE = Tag.of("exception", "None");
@@ -91,17 +85,6 @@ public static Tag status(Result result) {
9185
* @return the uri tag derived from the request result
9286
*/
9387
public static Tag uri(Result result, Function<Result, String> successfulUriPattern) {
94-
Response response = result.getResponse();
95-
if (response != null) {
96-
int status = response.getStatus();
97-
if (HttpStatus.isRedirection(status)) {
98-
return URI_REDIRECTION;
99-
}
100-
if (status == 404) {
101-
return URI_NOT_FOUND;
102-
}
103-
}
104-
10588
String matchingPattern = successfulUriPattern.apply(result);
10689
matchingPattern = MULTIPLE_SLASH_PATTERN.matcher(matchingPattern).replaceAll("/");
10790
if (matchingPattern.equals("/")) {
@@ -122,12 +105,6 @@ public static Tag exception(Result result) {
122105
if (exception == null) {
123106
return EXCEPTION_NONE;
124107
}
125-
if (result.getResponse() != null) {
126-
int status = result.getResponse().getStatus();
127-
if (status == 404 || HttpStatus.isRedirection(status)) {
128-
return EXCEPTION_NONE;
129-
}
130-
}
131108
if (exception.getCause() != null) {
132109
exception = exception.getCause();
133110
}

micrometer-jetty12/src/test/java/io/micrometer/jetty12/client/JettyClientMetricsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void notFound(WireMockRuntimeInfo wmRuntimeInfo) throws Exception {
151151
assertThat(registry.get("jetty.client.requests")
152152
.tag("outcome", "CLIENT_ERROR")
153153
.tag("status", "404")
154-
.tag("uri", "NOT_FOUND")
154+
.tag("uri", "/doesNotExist")
155155
.tag("host", "localhost")
156156
.timer()
157157
.count()).isEqualTo(1);

0 commit comments

Comments
 (0)