This commit migrates our remaining usage of the httpclient 4.x to use
instead httpclient5, now that the 4.x support has been removed in
`RestTemplate`.
Closes gh-32461
This commit adapts the `TestRestTemplate` implementation to the
httpclient5 API since httpclient 4.x is now unsupported in Spring
Framework.
See gh-32461
Prior to this commit, the `RestTemplateBuilder` would offer a generic
`setReadTimeout` method to configure the read timeout on the underlying
`ClientHttpRequestFactory`. This would be done in a reflective fashion,
considering that all implementations align with this behavior.
This option cannot be provided for HttpClient5 at the
`ClientHttpRequestFactory` level anymore, so this has been deprecated
in Spring Framework 6.0 and will log a warning. In order to align with
our existing behavior (throwing exceptions if the option cannot be set),
this commit ensures that exceptions are also thrown if the method is
marked as deprecated.
See gh-32461
As htttpclient 4.x is not supported anymore by `RestTemplate`, this
commit changes such dependencies to httpclient5 instead. In some cases,
the httpclient 4.x was transitively brought by a non-Spring dependency.
See gh-32461
Previously, RestTemplateBuilder and WebClient.Builder beans were used
to create the HTTP client for sending out spans. Those same beans are
also instrumented for observability which results in a cycle.
This commit breaks the cycle by not using the application-web
builders to create the RestTemplate and WebClient's used by the Zipkin
senders. Instead, builders are created inline, with new callbacks
being introduced to allow the user to customize these Zipkin-specific
builders.
See gh-32528
Previously, a Webclient-based sender was only for reactive web
applications, falling back to a RestTemplate-based sender in all
other cases.
With this commit we now prefer to use WebClient if it is available,
irrespective of the web application type. The assumption is that
if the user has WebClient on the classpath, it's either a reactive
web application, or it's a servlet web application or non-web
application but WebClient is preferred.
See gh-32529
Prior to this commit, Spring Boot would auto-configure a customizer that
instruments `RestTemplate` through a `RestTemplateBuilder`. This would
install a request interceptor that instrumented client exchanges for
producing metrics.
As of spring-projects/spring-framework#28341, the instrumentation is
done at the `RestTemplate` level directly using the `Observation` API.
The `Tag` (now `KeyValue`) extraction, observation name and
instrumentation behavior now lives in the Spring Framework project.
This commit updates the auto-configuration to switch from Boot-specific
Metrics instrumentation to a generic Observation instrumentation.
As a migration path, some configuration properties are deprecated in
favor of the new `management.observations.*` namespace.
Closes gh-32484