【发布时间】:2021-11-08 16:49:11
【问题描述】:
我想将应用程序的健康状态报告为指标,并且我希望使用与 spring-boot-actuator 相同的健康指标,但是,我没有看到 spring-boot-actuator 依赖项中的任何可导出组件我也许可以在这里使用。
我想写的代码:
@Component
public class HealthCounterMetric {
private final Counter statusCounter;
public HealthCounterMetric(MeterRegistry meterRegistry, SystemHealth systemHealth) {
this.statusCounter = meterRegistry.counter("service.status");
}
@Scheduled(fixedRate = 30000L)
public void reportHealth() {
//do report health
}
}
当然,SystemHealth 不是导出的 bean。 spring boot 执行器是否会导出我可以通过这种方式消费的 bean?
【问题讨论】:
标签: spring-boot spring-boot-actuator