我正在尝试使用codahale指标和metrics-spring包。我一直无法记录指标。
@Counted
public Response getSomething(@Context final HttpServletRequest request) {
return Response.ok(doWork()).build();
}
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:metrics="http://www.ryantenney.com/schema/metrics"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.ryantenney.com/schema/metrics
http://www.ryantenney.com/schema/metrics/metrics-3.0.xsd">
<!-- Registry should be defined in only one context XML file -->
<metrics:metric-registry id="metrics"/>
<!-- annotation-driven must be included in all context files -->
<metrics:annotation-driven metric-registry="metrics"/>
<!-- (Optional) Registry should be defined in only one context XML file -->
<metrics:reporter type="console" metric-registry="metrics" period="10s"/>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:metrics-spring.xml"/>
...snip....
当我在war文件中运行它并点击端点时,计数器不会递增。它保持在0
5/19/15 5:01:48 PM =============================================================
-- Counters --------------------------------------------------------------------
package.getSomething
count = 0
好像所有东西都正确连接在一起。数据被转储到控制台,它知道计数器。我做错了什么?