After upgrading to Spring Boot 2.6 with Micrometer 1.8.1 metric "http_server_requests_seconds_count" counts twice every jersey call with different uri tag: correct uri by org.springframework.boot.actuate.autoconfigure.metrics.jersey.JerseyServerMetricsAutoConfiguration UNKNOWN by org.springframework.boot.actuate.autoconfigure.metrics.web.servlet.WebMvcMetricsAutoConfiguration in that order (by filter priority)

jersey-metrics

Simple project for problem demonstration https://github.com/Declow0/jersey-metrics

Can WebMvcMetricsFilter ignore request for counting if Jersey implemetation was already counted?

Comment From: philwebb

Here's a Java version of the sample: https://github.com/philwebb/scratch-gh-29303

Comment From: philwebb

@Declow0 What version are you upgrading from? I tried 2.5 and I think I get the same result. Do you need to mix Spring MVC and Jersey in your application?

Comment From: Declow0

I upgraded from 2.3 to 2.6. Yes, I mix REST Controllers and Jersey endpoints (from Camunda project). At 2.3 I don't have Jersey metrics autoconfiguration and all Jersey call has uri tag = UNKNOWN

Comment From: philwebb

I'd like to discuss this one with the rest of the team to see if they have any ideas. I wonder if we might be able to tighten WebMvcMetricsFilter and only apply it if the request has been handled by a DispatcherServlet. Perhaps we can check for a DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE in the request.

Comment From: philwebb

See also #13064

Comment From: philwebb

We're going to look at adding a property that will allow WebMvcMetricsFilter to check if the request is from a DispatcherServlet. Since existing users might be relying on the existing behavior, we won't flip the default until Spring Boot 2.7.

Comment From: wilkinsona

We should also check what happens if Jersey's configured as a filter and with FILTER_FORWARD_ON_404. There's a chance that this will result in duplicate metrics as the request will have passed through Jersey and MVC's DispatcherServlet.

Comment From: anand188

I upgraded from 2.3 to 2.6. Yes, I mix REST Controllers and Jersey endpoints (from Camunda project). At 2.3 I don't have Jersey metrics autoconfiguration and all Jersey call has uri tag = UNKNOWN

Also facing same problem URI tag remain either UNKNOWN or /** instead actual endpoint urls? Any idea what might be wrong?

Comment From: bclozel

In the meantime, the observability support has been rewritten entirely and Jersey/MVC instrumentations are independent. Jersey apps should not depend on the web starter and as a result, the web layer will not be instrumented twice. Closing with https://github.com/spring-projects/spring-boot/issues/39294#issuecomment-1948529675

Comment From: cyril-telr

hi i have exactly same issue but for all count not only http, but database call, webclient calls etc all are counted twice

Comment From: wilkinsona

@cyril-telr in that case, it's not exactly the same issue. The problem that was tracked by this issue was specific to Jersey and how the web stack was instrumented. If you would like us to spend some time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can then share it with us by opening a new issue and pushing it to a separate repository on GitHub or by zipping it up and attaching it to the new issue.