I want to upgrade SpringBoot application from 2.x to latest version(3.3.3).
First of all I am aware of the changes introduced to metrics with SpringBoot 3.0.
Under Spring 2.x I had http.server.requests metrics where I could see a summary of the requests and different details (uri, status and also error and exception).
With SpringBoot 3.3.3 I still have http.server.requests but there are some differences.
- There are no errors nor exceptions. I “fixed” this by setting the error from my Exception Handler like suggested here: Spring Boot 3 micrometer http server requests metrics do not include exception and error tags . But I really don’t like this workaround.
- For 401 and 403 I don’t end up in the Exception Handler so I cannot apply the same logic. I tried to add a filter at the very end and to set there the error but I am not able to get my hands on the Observation Context. I did some tests with 401 call and in some cases it seems that I can see some AccessDeniedException under spring.security.authorizations.
My questions is what’s the easiest/cleanest way to have metrics as similar as in SpringBoot 2, e.g. have everything in http.server.requests with all details? It’s not only about changing the code but if metrics change other things have to change like monitoring dashboard, maybe metrics collection.