Hello,
I can use the Metrics timers and meters successfully (e.g. Metrics.newTimer(...) ).
However, I have no luck when using the metric annotations: no data gets reported to graphite and my console and jmx data remain equal to zero.
My spring context file has simply:
<metrics:annotation-driven />
The relevant part of my class is:
import com.yammer.metrics.annotation.ExceptionMetered;
import com.yammer.metrics.annotation.Metered;
import com.yammer.metrics.annotation.Timed;
...
@Component public class GetSessionServlet extends HttpServlet { private final static Logger log = LoggerFactory.getLogger(GetSessionServlet.class); @Override public void init(final ServletConfig config) throws ServletException { super.init(config); SpringBeanAutowiringSupport.processInjectionBasedOnServletContext( this, config.getServletContext());
ConsoleReporter.enable(1, TimeUnit.MINUTES);
GraphiteReporter.enable(1, TimeUnit.MINUTES, "<my host here>", 2003);
} @Override
@Metered
@Timed(name = "get-session", rateUnit = TimeUnit.MILLISECONDS) @ExceptionMetered(name = "get-session-failures", rateUnit = TimeUnit.MILLISECONDS) public void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final String sessionId = req.getParameter("sessionId"); final String fields = req.getParameter("fields"); final String format = req.getParameter("format"); if (StringUtils.isEmpty(sessionId)) { resp.getWriter().write("sessionId parameter missing!\n"); return; }
... }
(I also tried @Timed instead of @Timed(name = "get-session", rateUnit = TimeUnit.MILLISECONDS) with no more luck.)
I run my app locally with mvn clean tomcat7:run.
My console output keeps showing:
When using jconsole, in the MBeans tab, I can see an entry with the package name of my GetSessionServlet class with three subfolders doGet (for the @Metered numbers), get-session, and get-session-failures.
However, no matter how many times I call my servlet, all the values in the subfolders above remain at zero.