Reputation: 261
I'm trying to use Coda Hale's Metrics framework to time methods in my application. I've configured the InstrumentedResourceMethodApplicationListener to integrate Metrics with Jersey 2, but now I'd like my Spring injected services and repositories to also be timed. I know there's a metrics-spring integration but it looks like I would end up having separate MetricRegistry instances for Spring and Jersey. Has anyone been able to configure a single registry for both: the Jersey 2 resources and the Spring injected beans?
Upvotes: 0
Views: 673
Reputation: 1508
If you configure Jersey to use Spring you will be able to use metrics-spring for instrumenting spring beans. This should enable you define the InstrumentedResourceMethodApplicationListener
using a constructor argument to inject the Spring configured metrics repository:
<bean id="metricsListener" class="com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener">
<constructor-arg ref="metricsRegistry" />
</bean>
You may also want to configure the MetricsServlet.
Upvotes: 1