dropwizard
有没有办法使用in来测量 CPU 使用率和不同方面(CPU、线程、内存等)的利用率spring-boot
?
1 回答
为此使用spring-boot-actuator
。/metrics
您要求的数据已经有一个端点。
检查systemload.average
, mem
,mem.free
等threads
以获取确切信息。
欲了解更多信息检查:
https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html https://docs.spring.io/spring-boot/docs/current/reference/html /production-ready-metrics.html#production-ready-dropwizard-metrics
MetricRegistry
当您声明对库的依赖项时,将创建一个默认的Spring beanio.dropwizard.metrics:metrics-core
;如果您需要自定义,您也可以注册自己的@Bean
实例。Dropwizard 'Metrics' 库的用户会发现 Spring Boot 指标会自动发布到com.codahale.metrics.MetricRegistry
. 来自 的指标MetricRegistry
也通过/metrics
端点自动公开当 Dropwizard 指标正在使用时,默认值
CounterService
会GaugeService
被替换为DropwizardMetricServices
,它是 的包装器MetricRegistry
(因此您可以@Autowired
使用其中一个服务并正常使用它)。您还可以通过在您的指标名称前加上适当的类型来创建“特殊”Dropwizard 指标(即计时器。直方图。用于仪表,米。* 用于计数器)。