java—如何以编程方式使用执行器端点?

92dk7w1h  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(386)

我需要在spring启动应用程序中加入一些指标。所以我用了下面的metricsendpoint。但我无法获取指标。invoke()方法未出现。
spring boot版本:2.2.6.0

  1. @Controller
  2. public class DashboardControllerImpl implements IDashboardController {
  3. @Autowired
  4. private MetricsEndpoint metricsEndpoint;
  5. @Override
  6. public ResponseEntity listDiskUsage() {
  7. metricsEndpoint.invoke(); // invoke does not appear
  8. // code block
  9. }
  10. }
unhi4e5o

unhi4e5o1#

我找到了这样的东西,解决了我的问题!

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

相关问题