Skip to content

Commit

Permalink
Remove special handling of 404/301 JDK client instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
big-cir committed Jan 30, 2025
1 parent 44b1766 commit 97358ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,15 @@ public KeyValues getLowCardinalityKeyValues(HttpClientContext context) {
return KeyValues.of(
HttpClientObservationDocumentation.LowCardinalityKeys.METHOD.withValue(httpRequest.method()),
HttpClientObservationDocumentation.LowCardinalityKeys.URI
.withValue(getUri(httpRequest, context.getResponse(), context.getUriMapper())),
.withValue(getUri(httpRequest, context.getUriMapper())),
HttpClientObservationDocumentation.LowCardinalityKeys.STATUS
.withValue(getStatus(context.getResponse())),
HttpClientObservationDocumentation.LowCardinalityKeys.OUTCOME
.withValue(getOutcome(context.getResponse())));
}

String getUri(HttpRequest request, @Nullable HttpResponse<?> httpResponse,
Function<HttpRequest, String> uriMapper) {
return httpResponse != null && (httpResponse.statusCode() == 404 || httpResponse.statusCode() == 301)
? "NOT_FOUND" : uriMapper.apply(request);
String getUri(HttpRequest request, Function<HttpRequest, String> uriMapper) {
return uriMapper.apply(request);
}

String getStatus(@Nullable HttpResponse<?> response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private <T> void stopObservationOrTimer(
instrumentation.stop(DefaultHttpClientObservationConvention.INSTANCE.getName(), "Timer for JDK's HttpClient",
() -> Tags.of(HttpClientObservationDocumentation.LowCardinalityKeys.METHOD.asString(), request.method(),
HttpClientObservationDocumentation.LowCardinalityKeys.URI.asString(),
DefaultHttpClientObservationConvention.INSTANCE.getUri(request, res, uriMapper),
DefaultHttpClientObservationConvention.INSTANCE.getUri(request, uriMapper),
HttpClientObservationDocumentation.LowCardinalityKeys.STATUS.asString(),
DefaultHttpClientObservationConvention.INSTANCE.getStatus(res),
HttpClientObservationDocumentation.LowCardinalityKeys.OUTCOME.asString(),
Expand Down

0 comments on commit 97358ca

Please sign in to comment.