The WebMvcMetricsFilter is currently tied to Spring MVC but we'd also like to support Jersey and possibly general servlets. We could rework WebMvcMetricsFilter to MetricsFilter that provides the general code and create new technology specific strategies that can extract tags based on a specific technology.

Comment From: haykart

Dear Spring boot developers, I have a small question regarding WebMvcMetricsFilter: Did you planned to include the fix from https://github.com/spring-projects/spring-boot/pull/16014 PR to the 2.2.0.RELEASE?

Comment From: wilkinsona

@haykart please don't ask questions on unrelated issues. For the record, the changes proposed in #16104 are already in 2.2.0 snapshots and will, therefore, be included in 2.2.0.RELEASE.

Comment From: jkuipers

I also noted that when no MVC path mapping can be resolved, the request's pathInfo is used in the current implementation (org.springframework.boot.actuate.metrics.web.servlet.WebMvcTags#getPathInfo). What that means is that if e.g. a Spring Security filter prevents a request from reaching the DispatcherServlet, which is mapped as the default servlet in a default Boot app, the pathInfo is always null so the uri will always be reported as "root". The actual path is contained in the request's servletPath in this set-up, never in the pathInfo. I was surprised by this when our metrics suggested that requests were being made to the root of our app, even though these were actually to a different URL that would normally be handled by a Spring-MVC controller but were handled by a Spring Security filter instead in this case.

Maybe you could consider changing this if the support is being reworked anyway so that the uri reported matches the actual path.

Comment From: philwebb

@jkuipers That sounds like something we should address regardless. Do you by any chance have a small sample project that you could attach to a new issue?

Comment From: jkuipers

@jkuipers That sounds like something we should address regardless. Do you by any chance have a small sample project that you could attach to a new issue?

I just created #17147 with a demo project.

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