spring-cloud/spring-cloud-netflix

Missing observability support in RestTemplateTransportClientFactory

ZIRAKrezovic opened this issue · 2 comments

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 WebFlux WebClient 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

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

Reopening as changes reverted due to broken tests.