This is a follow-up to my struggle using yammer timing annotations as described here.
My spring context file has simply:
<metrics:annotation-driven />
I have the following class:
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());
}
@Override
@Timed(name = "get-session", rateUnit = TimeUnit.MILLISECONDS)
@Metered
@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 run my app locally with mvn clean tomcat7:run
and then connect 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 sub-folders above remain at zero. What am I missing? Also, any documentation on these metered metrics that goes into more details than the official documentation will be greatly appreciated.