本文介绍了尝试在 Spring Boot 中集成 Coda Hale Metrics,在/metrics 中没有看到指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照指示将 coda hale 指标库添加到类路径中会自动自动配置指标.

I have followed the indication that adding the coda hale metrics library into the classpath would automatically autoconfigure the metrics.

成功了,我得到了注入的 metricRegistry bean.

That works, I get the injected metricRegistry bean.

但是,如何在/metrics 端点中公开这些新指标?

However, how to I expose these new metrics in the /metrics endpoint?

谢谢!

推荐答案

这不是它应该的工作方式.Codahale 有一些指标类型不能映射到 Spring Boot,因此一旦开始以这种方式收集指标,您应该使用 Codahale 原生 API 进行报告.此时 Boot 仅提供 Gauge 和 Counter 的服务抽象.

That's not the way it's supposed to work. Codahale has some metric types that do not map to Spring Boot ones, so you are supposed to use the Codahale native APIs for reporting once you start collecting metrics that way. Boot is only providing the service abstraction for Gauge and Counter at that point.

更新:自 1.2.0 起,Spring Boot 还将 Codahale 指标添加到/metrics 端点(请参阅MetricRegistryMetricReader).

UPDATE: Spring Boot also adds Codahale metrics to the /metrics endpoint since 1.2.0 (see MetricRegistryMetricReader).

这篇关于尝试在 Spring Boot 中集成 Coda Hale Metrics,在/metrics 中没有看到指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 04:14