无法查看使用spring指标注释捕获的指标 [英] Unable to see metrics captured with spring metrics annotations

查看:195
本文介绍了无法查看使用spring指标注释捕获的指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该怎么做相同的:

  @Override
  public void init(final ServletConfig config) throws ServletException {
    super.init(config);
    CsvReporter.enable(new File("/tmp/measurements"), 1, TimeUnit.MINUTES);
    GraphiteReporter.enable(1, TimeUnit.MINUTES, "my.host.name", 2003);
  }

  @Override
  protected void doGet(final HttpServletRequest req,
          final HttpServletResponse resp) throws ServletException,
          IOException {
    final TimerContext timerContext = Metrics.newMeter(CreateSessionServlet.class,"myservlet-meter", "requests", TimeUnit.SECONDS).time();
    try {
...
  } finally {
      timerContext.stop();
    }

如上所述的春天注释和codahale指标这里

with spring annotations and codahale metrics as mentioned here?

我认为它会如此简单:

- 像这样注释我的servlet(我最终需要量表和计量):

-annotating my servlet like this (I will need gauges and metering eventually):

@Timed
@Gauge
@Metered
@Override
protected void doGet(final HttpServletRequest req,
        final HttpServletResponse resp) throws ServletException, IOException {

- 更新我的spring-servlet以启用弹簧注释,如上面提到的页面所述。

-and updating my spring-servlet to enable the spring annotations as explained on the page mentioned above.

但是当我使用jconsole时,我没有在MBeans部分看到我检测到的servlet的任何附加条目,而不是其他不使用任何注释的servlet

But when I use jconsole, I do not see in the MBeans section any additional entry for that servlet that I instrumented than for other servlets that do not use any annotation

所以我的两个问题:


  1. 我有什么遗漏,以便我的网站app实际上通过JMX发送度量数据?

  1. Is there anything I am missing so that my web app actually sends metric data via JMX?

如果我希望带有spring注释的代码开始报告CSV文件或石墨,我需要什么添加?

If I want the code with spring annotations to start reporting to a CSV file or to graphite, what do I need to add?

令人惊讶的是,我在网上或codahale的doc中找不到完整的例子。

Surprisingly I found no complete examples on the web or in the doc from codahale on this.

推荐答案

不幸的是,指标仅基于AOP,因此它只能用于公共方法

Unfortunately metrics only is based on AOP so that it could be used only for public method

这篇关于无法查看使用spring指标注释捕获的指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆