I think I did it.
The first thing I noticed was that the URI in the schemaLocation attribute of the spring test file: http://www.yammer.com/schema/metrics/metrics.xsd returns a 404 error.
I looked for this problem to find out if anyone regretted the unavailability of the scheme and found this thread github.com/codahale/metrics/issues/322, in which the user comments that the spring metrics module has been removed from the main metrics repository and moved at: github.com/ryantenney/metrics-spring.
Following the example on this website, I removed the old spring metric from my pump and added the following:
<dependency> <groupId>com.ryantenney.metrics</groupId> <artifactId>metrics-spring</artifactId> <version>2.1.4</version> </dependency>
Then I updated the xmlns declaration in spring -context.xml:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:metrics="http://www.ryantenney.com/schema/metrics" xsi:schemaLocation=" http://www.ryantenney.com/schema/metrics http://www.ryantenney.com/schema/metrics/metrics.xsd ...other schemas...">
Added annotation driven element:
<metrics:annotation-driven proxy-target-class="true" />
I have included proxy-target-class for working with class-based startup.
And in the bean, I wanted Time to add the @Timed annotation and the @PostConstruct method to allow ConsoleReporter to reset statistics every 10 seconds:
@PostConstruct public void init() { ConsoleReporter.enable(10, TimeUnit.SECONDS); } @Timed public void doService(...) { .... do stuff .... }
Then I ran my webapp .... and got an unpleasant error from the sax parser while parsing the spring context.xml file.
It looks like www.ryantenney.com/schema/metrics/metrics.xsd 404s!
The workaround for this was simple, however I downloaded xsd from the github repository: https://github.com/ryantenney/metrics-spring/blob/master/src/main/resources/com/ryantenney/metrics/spring/config/metrics -3.0.xsd
and then the following files are added to the src / main / resources / META-INF directory of my maven project:
META-INF/ - spring.schemas - xsd/ - metrics.xsd
where metrics.xsd is the xsd file downloaded from github and spring.schemas is a text file containing:
http\://www.ryantenney.com/schema/metrics/metrics.xsd=META-INF/xsd/metrics.xsd
The spring.schemas file is read by spring at startup and tells it to output xsd from the local file.
With the above, I was able to successfully launch my application and click on the endpoint that used the service method.
Watching the console, I really saw the following resetting every 10 seconds:
com.sample.service.MyServiceClass: doService: count = 8 mean rate = 0.27 calls/s 1-minute rate = 0.23 calls/s 5-minute rate = 0.21 calls/s 15-minute rate = 0.20 calls/s min = 0.13ms max = 19.59ms mean = 2.59ms stddev = 6.87ms median = 0.18ms