From e69385de92be0c57eb5ec4fae958c82f50044cf5 Mon Sep 17 00:00:00 2001 From: bigcir Date: Thu, 30 Jan 2025 15:30:47 +0900 Subject: [PATCH] Remove special handling of 404/301 JDK client instrumentation See gh-5812 Signed-off-by: bigcir --- .../jdk/DefaultHttpClientObservationConvention.java | 8 +++----- .../instrument/binder/jdk/MicrometerHttpClient.java | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/micrometer-java11/src/main/java/io/micrometer/java11/instrument/binder/jdk/DefaultHttpClientObservationConvention.java b/micrometer-java11/src/main/java/io/micrometer/java11/instrument/binder/jdk/DefaultHttpClientObservationConvention.java index 75259f8618..d1e3983d33 100644 --- a/micrometer-java11/src/main/java/io/micrometer/java11/instrument/binder/jdk/DefaultHttpClientObservationConvention.java +++ b/micrometer-java11/src/main/java/io/micrometer/java11/instrument/binder/jdk/DefaultHttpClientObservationConvention.java @@ -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 uriMapper) { - return httpResponse != null && (httpResponse.statusCode() == 404 || httpResponse.statusCode() == 301) - ? "NOT_FOUND" : uriMapper.apply(request); + String getUri(HttpRequest request, Function uriMapper) { + return uriMapper.apply(request); } String getStatus(@Nullable HttpResponse response) { diff --git a/micrometer-java11/src/main/java/io/micrometer/java11/instrument/binder/jdk/MicrometerHttpClient.java b/micrometer-java11/src/main/java/io/micrometer/java11/instrument/binder/jdk/MicrometerHttpClient.java index 23970ce08d..2aeb78a3d4 100644 --- a/micrometer-java11/src/main/java/io/micrometer/java11/instrument/binder/jdk/MicrometerHttpClient.java +++ b/micrometer-java11/src/main/java/io/micrometer/java11/instrument/binder/jdk/MicrometerHttpClient.java @@ -235,7 +235,7 @@ private 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(),