From 0acaa0e46050017e75056d51918d447271fc16c7 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 2 Nov 2022 18:39:10 +0100 Subject: [PATCH] Adapt to observation changes in Framework See spring-projects/spring-framework#29388 --- .../web/client/ClientObservationConventionAdapter.java | 6 +++--- .../web/client/ClientObservationConventionAdapterTests.java | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapter.java index a36e4d11d2..6466202b8a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapter.java @@ -56,16 +56,16 @@ class ClientObservationConventionAdapter implements ClientRequestObservationConv @Override public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) { mutateClientRequest(context); - Iterable tags = this.tagsProvider.tags(context.getCarrier(), context.getResponse(), context.getError()); + Iterable tags = this.tagsProvider.tags(context.getRequest(), context.getResponse(), context.getError()); return KeyValues.of(tags, Tag::getKey, Tag::getValue); } private void mutateClientRequest(ClientRequestObservationContext context) { // WebClientExchangeTagsProvider relies on a request attribute to get the URI // template, we need to adapt to that. - ClientRequest clientRequest = ClientRequest.from(context.getCarrier()) + ClientRequest clientRequest = ClientRequest.from(context.getRequest()) .attribute(URI_TEMPLATE_ATTRIBUTE, context.getUriTemplate()).build(); - context.setCarrier(clientRequest); + context.setRequest(clientRequest); } @Override diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapterTests.java index 590eac5378..6740fd4154 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapterTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapterTests.java @@ -45,7 +45,7 @@ class ClientObservationConventionAdapterTests { private ClientObservationConventionAdapter convention = new ClientObservationConventionAdapter(TEST_METRIC_NAME, new DefaultWebClientExchangeTagsProvider()); - private ClientRequest request = ClientRequest.create(HttpMethod.GET, URI.create("/resource/test")).build(); + private ClientRequest.Builder requestBuilder = ClientRequest.create(HttpMethod.GET, URI.create("/resource/test")); private ClientResponse response = ClientResponse.create(HttpStatus.OK).body("foo").build(); @@ -54,7 +54,8 @@ class ClientObservationConventionAdapterTests { @BeforeEach void setup() { this.context = new ClientRequestObservationContext(); - this.context.setCarrier(this.request); + this.context.setCarrier(this.requestBuilder); + this.context.setRequest(this.requestBuilder.build()); this.context.setResponse(this.response); this.context.setUriTemplate("/resource/{name}"); }