codahale指标未被记录

时间:2015-05-20 17:30:57

标签: spring codahale-metrics

我正在尝试使用codahale指标和metrics-spring包。我一直无法记录指标。

函数调用

@Counted
public Response getSomething(@Context final HttpServletRequest request) {
  return Response.ok(doWork()).build();
}

度量-spring.xml

<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>

的beans.xml

<?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

好像所有东西都正确连接在一起。数据被转储到控制台,它知道计数器。我做错了什么?

0 个答案:

没有答案