3

我正在寻找 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,包含版本、gaugues、计数器、计时器标签等(如在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,如下所示:

豆子 = { metricRegistry(MetricRegistry) }

但输出 JSON 仍然是相同的。

请让我缺少什么。提前致谢!

4

0 回答 0