spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.87k stars 2.44k forks source link

Missing observability support in RestTemplateTransportClientFactory #4255

Closed ZIRAKrezovic closed 6 months ago

ZIRAKrezovic commented 7 months ago

Describe the bug

I have just spent some hours debugging why RestTemplate is not propagating traces to Eureka Server. Turns out RestTemplateTransportClientFactory creates a RestTemplate instance by calling new RestTemplate().

To fix this, RestTemplate.Builder should be used to create a RestTemplate in RestTemplateTransportClientFactory and we get observability support for free.

Now consider the WebFluxWebClient equivalent

public WebClientTransportClientFactories webClientTransportClientFactories(
        ObjectProvider<WebClient.Builder> builder) {
    return new WebClientTransportClientFactories(builder::getIfAvailable);
}

Here, as expected, the WebClient.Builder is used, and produced TransportClientFactory has observability support ...

Version: Spring Cloud Starter 2023.0.0

OlgaMaciaszek commented 6 months ago

Thanks for reporting the issue, @ZIRAKrezovic. Makes sense.

OlgaMaciaszek commented 6 months ago

Reopening as changes reverted due to broken tests.