Adapt to observation changes in Framework

See spring-projects/spring-framework#29388
pull/32994/head
Brian Clozel 2 years ago
parent 05c5b1225c
commit 0acaa0e460

@ -56,16 +56,16 @@ class ClientObservationConventionAdapter implements ClientRequestObservationConv
@Override
public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) {
mutateClientRequest(context);
Iterable<Tag> tags = this.tagsProvider.tags(context.getCarrier(), context.getResponse(), context.getError());
Iterable<Tag> 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

@ -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}");
}

Loading…
Cancel
Save