Grails dropwizard-metrics插件不会以正确的格式输出度量标准数据

时间:2017-03-06 06:37:40

标签: grails dropwizard grails-3.0 grails3

我一直在寻找替换Grails 3.x&的yammer-metrics插件发现Grails Dropwizard Metrics也是如此。

我试图将它与我的示例应用程序(在Grails 3.x中)集成,并遵循以下文档: http://grails-plugins.github.io/grails-dropwizard-metrics/snapshot/index.html#_healthcheck_beans

在博客之后,我在build.gradle中添加了以下依赖项,即

compile "org.grails.plugins:dropwizard-metrics:1.0.0.BUILD-SNAPSHOT"

为了测试这个,我使用index()动作创建了TestController,即

import grails.plugin.dropwizard.metrics.timers.Timed

class TestController {

    @Timed('test1')
    def index() {
        render 'ok'
    }
}

通过这个,运行应用程序并点击/ test / index然后/ metrics,不再返回有效的JSON,包含版本,标记,计数器,计时器标记等(如http://grails-plugins.github.io/grails-dropwizard-metrics/snapshot/index.html#_exposing_metrics_data中所示)

相反,它只是以这种格式返回JSON:

{
    "mem": 830779,
    "mem.free": 602088,
    "processors": 4,
    "instance.uptime": 14766,
    "uptime": 30991,
    "systemload.average": -1.0,
    "heap.committed": 749056,
    "heap.init": 786432,
    "heap.used": 146967,
    "heap": 749056,
    "nonheap.committed": 84896,
    "nonheap.init": 2496,
    "nonheap.used": 81724,
    "nonheap": 0,
    "threads.peak": 33,
    "threads.daemon": 29,
    "threads.totalStarted": 37,
    "threads": 32,
    "classes": 11057,
    "classes.loaded": 11057,
    "classes.unloaded": 0,
    "gc.ps_scavenge.count": 18,
    "gc.ps_scavenge.time": 490,
    "gc.ps_marksweep.count": 3,
    "gc.ps_marksweep.time": 854,
    "test1.snapshot.stdDev": 0,
    "gauge.response.test.test1": 335.0,
    "gauge.response.assets.bootstrap.js": 76.0,
    "test1.snapshot.98thPercentile": 31,
    "counter.status.200.assets.grails.css": 1,
    "gauge.response.assets.jquery-2.2.0.min.js": 146.0,
    "test1.snapshot.999thPercentile": 31,
    "counter.status.200.test.test1": 1,
    "gauge.response.assets.grails-cupsonly-logo-white.svg": 3.0,
    "test1.fifteenMinuteRate": 0.2,
    "test1.snapshot.min": 31,
    "test1.snapshot.95thPercentile": 31,
    "test1.meanRate": 0.18974713564659287,
    "gauge.response.assets.favicon.ico": 8.0,
    "gauge.response.assets.mobile.css": 129.0,
    "gauge.response.root": 2301.0,
    "counter.status.200.root": 1,
    "counter.status.200.assets.jquery-2.2.0.min.js": 1,
    "counter.status.200.assets.application.css": 1,
    "gauge.response.assets.main.css": 148.0,
    "test1.snapshot.mean": 31,
    "test1.snapshot.99thPercentile": 31,
    "counter.status.200.assets.main.css": 1,
    "gauge.response.assets.application.css": 152.0,
    "counter.status.200.assets.mobile.css": 1,
    "counter.status.200.assets.grails-cupsonly-logo-white.svg": 1,
    "test1.snapshot.median": 31,
    "gauge.response.assets.grails.css": 145.0,
    "counter.status.200.assets.bootstrap.js": 1,
    "test1.count": 1,
    "test1.oneMinuteRate": 0.2,
    "test1.fiveMinuteRate": 0.2,
    "test1.snapshot.max": 31,
    "test1.snapshot.75thPercentile": 31,
    "gauge.response.assets.application.js": 4.0,
    "counter.status.200.assets.favicon.ico": 2,
    "counter.status.200.assets.application.js": 1,
    "gauge.response.assets.bootstrap.css": 249.0,
    "counter.status.200.assets.bootstrap.css": 1,
    "httpsessions.max": -1,
    "httpsessions.active": 0
}

在我的示例应用程序中,我曾尝试在resources.groovy中注册MetricRegistry bean,如下所示:

beans = {   metricRegistry(MetricRegistry) }

但输出JSON仍然相同。

请告诉我我缺少的东西。 提前谢谢!

0 个答案:

没有答案