Since spring-projects/spring-framework#28341, Spring Framework now instruments directly WebClient, removing the need for a custom ExchangeFunction.
With this issue, we should update the auto-configuration to only rely on the new ObservationRegistry and configure the instrumentation available on WebClient. We need to provide a smooth upgrade experience: deprecate the tags providers and adapt them to the new infrastructure until it's completely removed.
Comment From: bclozel
As part of this change, we've deprecated DefaultWebClientExchangeTagsProvider, WebClientExchangeTagsProvider and WebClientExchangeTags.
If an application needs to change the KeyValues (formerly Tags) for this observation, you can contribute a bean of type GlobalObservationConvention for the observation context we're considering.
Instead of inheriting from DefaultWebClientExchangeTagsProvider, we can here extend the DefaultClientObservationConvention and override the methods we want.
Here, let's add a "httpMethod" keyvalue by extracting the value from the request:
public class CustomClientObservationConvention extends DefaultClientObservationConvention
implements GlobalObservationConvention<ClientObservationContext> {
@Override
public KeyValues getLowCardinalityKeyValues(ClientObservationContext context) {
KeyValues keyValues = super.getLowCardinalityKeyValues(context);
ClientRequest request = context.getCarrier();
return keyValues.and("httpMethod", request.method().name());
}
}