Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove special handling of 404 and redirection statuses from Jetty client instrumentation #5825

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading