Migrating to Spring Boot 3.4+ WebClient Metrics with Reactive Observability
Автор: vlogommentary
Загружено: 2025-12-16
Просмотров: 3
Описание:
Learn how to update your Spring Boot 3.4+ WebFlux app to collect accurate HTTP client metrics with the new Observability API, replacing the deprecated MetricsWebClientFilterFunction.
---
This video is based on the question https://stackoverflow.com/q/79500687/ asked by the user 'donm' ( https://stackoverflow.com/u/1475386/ ) and on the answer https://stackoverflow.com/a/79506701/ provided by the user 'donm' ( https://stackoverflow.com/u/1475386/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.
Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Spring boot 3.4+ webclient reactive depracated metrics filter alternative
Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.
If anything seems off to you, please feel free to drop me a comment under this video.
---
Introduction
Spring Boot 3.4 introduced a new Observability API that replaces the older metrics filtering approach used in reactive WebClient applications. If you've relied on MetricsWebClientFilterFunction previously to capture Prometheus metrics, your configuration now needs an update to work correctly with HTTP client request metrics.
The Problem
Previously, Spring Boot 2.x apps used a filter function like this:
[[See Video to Reveal this Text or Code Snippet]]
This approach allowed detailed metrics including URI tags.
In Spring Boot 3.4+ , this is no longer supported and switching to:
[[See Video to Reveal this Text or Code Snippet]]
alone results in metrics with uri="UNKNOWN". Attempts to customize conventions or use @ Observable annotations might not resolve the issue.
The Updated Solution with Spring Boot 3.4+ Observability
To regain detailed HTTP client metrics, follow these steps:
1. Inject the ObservationRegistry
Make sure your ObservationRegistry is available to your WebClient config:
[[See Video to Reveal this Text or Code Snippet]]
2. Configure WebClient Builder Properly
Use the new Observation API conventions:
[[See Video to Reveal this Text or Code Snippet]]
observationRegistry(registry): Enables observability hooks.
observationConvention(...) assigns a meaningful client name that appears in metrics.
3. Use the WebClient With Parameterized URIs
Make sure you pass URI variables properly so that metrics capture the actual endpoint paths:
[[See Video to Reveal this Text or Code Snippet]]
This setup ensures Prometheus metrics like:
[[See Video to Reveal this Text or Code Snippet]]
No more uri="UNKNOWN" metrics.
Key Takeaways
MetricsWebClientFilterFunction is deprecated in Spring Boot 3.4+ .
Use ObservationRegistry and DefaultClientRequestObservationConvention for reactive WebClient metrics.
Parameterize WebClient URIs properly for correct URI tags in metrics.
Configure the ReactorClientHttpConnector explicitly if customizing the underlying HTTP client.
This approach conforms with Spring Boot’s evolving observability standards and ensures accurate, actionable metrics for your reactive HTTP clients.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: