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
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)
LongTaskTimingHandlerInterceptor will all take effect.
They conflict with each other.
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
TimedAspect default tag keys specified is
[class, exception, method]
WebMvcMetricsFilter default tag keys specified is
[exception, method, outcome, status, uri]