Ask questionsController annotated with @Timed and active TimedAspect clashes with WebMvcMetricsFilter

tl;dr A demo can be found here:

When the controller is called an unhandled exception is raised, by WebMvcMetricsFilter as org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter#stop tries to register the same meter with different tags as already registered by the TimedAspect. There is afais no way to disable the behaviour of WebMvcMetricsFilter for this aspect.

To generate prometheus percentiles via micrometer for my controllers I added @Timed("some_name") to a few methods. Unluckily this caused issues in WebMvcMetricsFilter which we use to monitor our status codes.

java.lang.IllegalArgumentException: Prometheus requires that all meters with the same name have the same set of tag keys. There is already an existing meter containing tag keys [class, exception, method]. The meter you are attempting to register has keys [exception, method, outcome, status, uri].


Answer questions sycz

I found the same problem. When using

@Timed(value = "metric_name", longTask = true)

WebMvcMetricsFilterand LongTaskTimingHandlerInterceptor will all take effect. They conflict with each other.

Fortunately, io.micrometer.core.aop.TimedAspect is not enabled by default, unless manually enabled. My understanding is that this means belonging to a user-defined operation.

LongTaskTimingHandlerInterceptor default tag keys specified is [method, uri] TimedAspect default tag keys specified is[class, exception, method] WebMvcMetricsFilter default tag keys specified is [exception, method, outcome, status, uri]



Related questions

Dependency resolution fails with Gradle 5.3.x to 5.6.x hot 4
Actuator: NPE in LongTaskTimingHandlerInterceptor hot 2
ConfigurationProperties with constructor binding cannot be mocked hot 2
NoClassDefFoundError: net/bytebuddy/NamingStrategy$SuffixingRandom$BaseNameResolver hot 2
Deadlock between BackgroundPreinitializer and main thread in Spring Cloud Config Server hot 2
spring boot Servlet.service() for servlet [dispatcherServlet] in context with path threw exception hot 2
Migrating OAuth2 from Spring Boot 1.5 to 2.0 Broken hot 2
Add AutoConfiguration support for spring-security-saml2-service-provider hot 2
Replace deprecated MediaType.APPLICATION_JSON_UTF8 usage hot 2
Classloading problems with Spring Boot, JDK11 and Security Manager hot 1
java.lang.NullPointerException: null occurs in HttpExchangeTracer hot 1
Multiple data source projects cannot be started hot 1
get error messag Could not fetch the SequenceInformation from the database, hibernate_sequence doesn't exist hot 1
HttpTraceFilter bean missing hot 1
A java.lang.NoClassDefFoundError: ch/qos/logback/classic/spi/ThrowableProxy was thrown when killing my app hot 1
Github User Rank List