Skip to content

Commit

Permalink
Remove special handling of 404 and redirection statuses from Jetty cl…
Browse files Browse the repository at this point in the history
…ient instrumentation (#5825)

See gh-5812

Signed-off-by: dae won <[email protected]>
  • Loading branch information
big-cir authored Jan 27, 2025
1 parent c39bda3 commit 0540899
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -100,16 +95,6 @@ public static KeyValue status(@Nullable Result result) {
*/
public static KeyValue uri(Request request, @Nullable Result result,
BiFunction<Request, Result, String> 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("/")) {
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -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<Result, String> 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("/")) {
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0540899

Please sign in to comment.