spring-cloud-netflix icon indicating copy to clipboard operation
spring-cloud-netflix copied to clipboard

Missing observability support in RestTemplateTransportClientFactory

Open ZIRAKrezovic opened this issue 1 year ago • 0 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

ZIRAKrezovic avatar Feb 19 '24 16:02 ZIRAKrezovic