Instrument RestTemplate for Observability

This commit introduces Micrometer as an API dependency to the spring-web
module. Micrometer is used here to instrument `RestTemplate` and record
`Observation` for HTTP client exchanges.

This will replace Spring Boot's `MetricsClientHttpRequestInterceptor`
which uses the request interceptor contract for instrumentation.
This approach is limited as measurements and tags aren't always precise
and overhead is more important than a direct instrumentation.

See gh-28341
This commit is contained in:
Brian Clozel
2022-09-12 11:36:32 +02:00
parent a68b46a2b6
commit a0ddcd07c8
9 changed files with 804 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ apply plugin: "kotlinx-serialization"
dependencies {
api(project(":spring-beans"))
api(project(":spring-core"))
api("io.micrometer:micrometer-observation")
compileOnly("io.projectreactor.tools:blockhound")
optional(project(":spring-aop"))
optional(project(":spring-context"))
@@ -74,6 +75,7 @@ dependencies {
testImplementation("org.xmlunit:xmlunit-assertj")
testImplementation("org.xmlunit:xmlunit-matchers")
testImplementation("io.projectreactor.tools:blockhound")
testImplementation("io.micrometer:micrometer-observation-test")
testRuntimeOnly("com.sun.mail:jakarta.mail")
testRuntimeOnly("com.sun.xml.bind:jaxb-core")
testRuntimeOnly("com.sun.xml.bind:jaxb-impl")