2014-11-02 87 views
0

我想在我的应用程序中使用Coda Hale的指标框架来计算方法。我配置了InstrumentedResourceMethodApplicationListener以将度量与Jersey 2集成,但是现在我想让我的Spring注入的服务和存储库也定时。我知道有一个指标 - 弹簧整合,但看起来我最终会为Spring和Jersey单独使用MetricRegistry实例。有没有人能够为Jersey 2和Spring注入bean配置一个注册表?春季4 +泽西岛2 +度量

回答

1

如果您配置Jersey to use Spring,您将可以使用metrics-spring来装配弹簧豆。这将使你定义InstrumentedResourceMethodApplicationListener使用构造函数参数注入春天配置指标库:

<bean id="metricsListener" class="com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener"> 
    <constructor-arg ref="metricsRegistry" /> 
</bean> 

您可能还需要configure the MetricsServlet