-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Describe the bug
When upgrading our applications to Spring Boot 3.2.0, we noticed that we stopped getting spans from http client invocations. After some digging, we think the reason is that the http request factory has changed: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#resttemplate-http-clients
If we opt in to JdkClientHttpRequestFactory, as described, tracing works. However, Apache HttpClient 5 request factory, or the jetty 12 client factory, does not seem to work. For Apache Http Client 5, the problem seem to be that Spring send null as HttpHost here: https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequest.java#L95
which results in a NullPointerException in RequestWithHost:
public RequestWithHost(HttpHost httpHost, ClassicHttpRequest httpRequest) {
super(httpRequest);
this.scheme = httpHost.getSchemeName();
this.authority = new URIAuthority(httpHost.getHostName(), httpHost.getPort());
}Intuitive fix is to fetch URIAuthority and scheme from httpRequest:
this.scheme = httpRequest.getScheme();
this.authority = httpRequest.getAuthority();but perhaps there is a reason this is not done in the first place.
For Jetty 12 http client, it seems that support just does not exist.
Steps to reproduce
- Create a new Spring Boot 3.2.0 application
- Add Apache HttpClient 5 or Jetty 12 Http Client to classpath.
- Create endpoint using RestClient to invoke a http service
Expected behavior
Span is created for the RestClient call
Actual behavior
No span is created
Javaagent or library instrumentation version
1.32.0
Environment
JDK: Azul 17
OS: MacOS
Additional context
No response