Spring Boot has WebMvcMetricsFilter
and WebMvcMetricsAutoConfiguration
that "magically" instruments all RequestMappings and similar with Micrometer metrics.
It would be great if this was possible to do in a core Spring project too.
(On a general note, I find this happens often now: Boot gets new tricks and features which just as well could have been introduced in core Spring, and benefit both types of projects. This is sad.)
PS: I find the solution for this instrumenting to be a bit .. high level? One would maybe have thought that Spring easily could have instrumented this on a lower level - directly on the mappings - thereby directly taking advantage of the knowledge of the path with path variables etc.
Comment From: bclozel
As announced at SpringOne 2021, the Spring team is working on new observability efforts across the portfolio. Possibly coming up with a high level API that would allow to instrument projects without depending on actual implementations.
This problem can be split into several parts:
- Instrumenting Framework code in specific places
- Configuring the broader metrics ecosystem (Micrometer, Sleuth, monitoring system, etc)
- Instrumenting for metrics that are specific to the deployment arrangement
- Configuring the entire infrastructure
We can only look into 1) in Spring Framework. 2) 3) and 4) require way more opinions on the choice of dependencies and deployment. This is really tied to how Spring Boot applications are deployed and set up. Shipping a generic implementation that is applicable to many deployment opinions is way more challenging.
Comment From: bclozel
Closing in favor of #28880