Search code examples
javaspringtomcatmetricsmetrics-spring

get the 2 identical interceptorsAndDynamicMethodMatchers for @Timed metrics-spring


I am using Spring 4.2.5, Jersey 2.22.2, Tomcat 8.0, io.dropwizard.metrics 3.1.2, metrics-spring 3.1.2

I am using @Timed annotation and found that for the method invocation, there are two TimedMethodInterceptor in the interceptorsAndDynamicMethodMatchers. It ends up the count doubles the real method invocation.

If I run the same webapp using Jetty Runner in Intellij IDEA, I don't see the problem. Any clue?

Just debugged a bit, there two BeanPostProcessors with Timed annotations. enter image description here


Solution

  • I finally figured out what caused it. Tomcat unpack the war file and create directory in both Catalinahome/webapps and Catalinahome/work directory which somehow caused the issue. If I set unpackWARs attribute set to "false", the issue is gone.