【问题标题】:How to use actuator endpoints programmatically?如何以编程方式使用执行器端点?
【发布时间】:2020-12-05 14:39:01
【问题描述】:

我需要一些指标到 Spring Boot 应用程序中。所以我使用了 MetricsEndpoint,如下所示。但我无法访问指标。 invoke() 方法没有出现。

spring boot 版本:2.2.6.RELEASE

@Controller
public class DashboardControllerImpl implements IDashboardController {

    @Autowired
    private MetricsEndpoint metricsEndpoint;

    @Override
    public ResponseEntity listDiskUsage() {
        metricsEndpoint.invoke(); // invoke does not appear

        // code block
    }
}

【问题讨论】:

    标签: java spring-boot metrics spring-boot-actuator


    【解决方案1】:

    我找到了类似的东西,解决了我的问题!

    ((MetricsEndpoint.Sample)metricsEndpoint.metric("process.uptime", null).getMeasurements().get(0)).getValue()
    

    【讨论】:

      猜你喜欢
      • 2015-03-14
      • 2020-02-11
      • 2014-11-10
      • 1970-01-01
      • 2013-12-29
      • 2012-07-19
      • 1970-01-01
      • 2019-09-29
      • 1970-01-01
      相关资源
      最近更新 更多