Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrument HTTP clients for Observability #28341

Closed
bclozel opened this issue Apr 14, 2022 · 0 comments
Closed

Instrument HTTP clients for Observability #28341

bclozel opened this issue Apr 14, 2022 · 0 comments
Assignees
Labels
theme: observability An issue related to observability and tracing type: enhancement A general enhancement
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Apr 14, 2022

Micrometer 1.10 will bring a new micrometer-observation module - this will bring a lightweight API designed for instrumenting code for observability (both metrics and tracing concerns).

We'd like to introduce a compile dependency on that in the spring-web module, which will allow us to instrument RestTemplate and WebClient. This should not only make the instrumentation more efficient and focused, but also fix a number of limitations of the current instrumentation contributed in Spring Boot.

@bclozel bclozel added type: enhancement A general enhancement theme: observability An issue related to observability and tracing labels Apr 14, 2022
@bclozel bclozel added this to the 6.0.0-M4 milestone Apr 14, 2022
@bclozel bclozel self-assigned this Apr 14, 2022
@bclozel bclozel modified the milestones: 6.0.0-M4, 6.0.0-M5 May 9, 2022
@bclozel bclozel modified the milestones: 6.0.0-M5, 6.0.0-M6 Jul 11, 2022
bclozel added a commit that referenced this issue Sep 12, 2022
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
bclozel added a commit that referenced this issue Sep 12, 2022
This commit introduces Micrometer as an API dependency to the
spring-webflux module. Micrometer is used here to instrument `WebClient`
and record `Observation` for HTTP client exchanges.

This replaces Spring Boot's `MetricsWebClientFilterFunction` which
instruments `WebClient` via an `ExchangeFilterFunction`. Here, a direct
instrumentation is more efficient and less prone to metrics errors.

See gh-28341
bclozel added a commit that referenced this issue Sep 12, 2022
bclozel added a commit that referenced this issue Sep 13, 2022
@bclozel bclozel closed this as completed Sep 13, 2022
bclozel added a commit to spring-projects/spring-boot that referenced this issue Sep 27, 2022
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
bclozel added a commit to spring-projects/spring-boot that referenced this issue Sep 30, 2022
As of spring-projects/spring-framework#28341, `WebClient` is
instrumented directly for `Observation`.
This commit removes the custom `ExchangeFilterFunction` that previously
instrumented the client for metrics.

As a result, the relevant tag providers are now deprecated and adapted
as `ObservationConvention` for the time being.

Closes gh-32518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: observability An issue related to observability and tracing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant