Since spring-projects/spring-framework#28341, Spring Framework now instruments directly RestTemplate, removing the need for a custom request interceptor (with well known limitations).

With this issue, we should update the auto-configuration to only rely on the new ObservationRegistry and configure the instrumentation available on RestTemplate. 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 DefaultRestTemplateExchangeTagsProvider, RestTemplateExchangeTagsProvider and RestTemplateExchangeTags.

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 DefaultRestTemplateExchangeTagsProvider, we can here extend the DefaultClientHttpObservationConvention and override the methods we want.

Here, let's add a "httpMethod" keyvalue by extracting the value from the request:

public class CustomClientHttpObservationConvention extends DefaultClientHttpObservationConvention
        implements GlobalObservationConvention<ClientHttpObservationContext> {

    @Override
    public KeyValues getLowCardinalityKeyValues(ClientHttpObservationContext context) {
        KeyValues keyValues = super.getLowCardinalityKeyValues(context);
        ClientHttpRequest request = context.getCarrier();
        return keyValues.and("httpMethod", request.getMethod().name());
    }

}