我有一个spring引导应用程序,它使用基于resilience4j AOP的@CircuitBreaker。
现在,我想在/actuator/health端点中提供断路器的信息,但我在JSON输出中没有看到details.circuitBtreakers对象在文档中描述。
我做错了什么?
相比之下,要在/actuator/metrics端点中显示动态缓存信息需要少量的自定义连接,但这是有据可查。我想知道是否有类似的技巧,我可以申请动态定义的@CircuitBreaker在/actuator/health端点中注册。
MyService.java**:**
@Service
public class MyService {
@Autowired
private CacheManager cacheManager;
@Autowired
private CacheMetricsRegistrar cacheMetricsRegistrar;
@PostConstruct
public void postConstruct() {
// On-the-fly defined (annotation-based) caches are not auto-registered with micrometer metrics.
final Cache cache = cacheManager.getCache("myCache");
cacheMetricsRegistrar.bindCacheToRegistry(cache);
}
@CircuitBreaker(name = "myCB", fallbackMethod = "fallbackCallAnApi")
public String callAnApi() throws RestClientException {
// ...
}
@Cacheable("myCache")
public String getSomethingCacheable() {
// ...
}
}application.properties**:**
resilience4j.circuitbreaker.configs.default.registerHealthIndicator=true
management.endpoints.web.expose=health,metrics
management.endpoints.web.exposure.include=health,metrics
management.endpoint.health.enabled=true
management.endpoint.metrics.enabled=true
management.metrics.enable.resilience4j.circuitbreaker.calls=true
management.health.circuitbreakers.enabled=true发布于 2020-03-05 06:33:43
动态地为CircuitBreakers端点注册HealthIndicator当前无法工作。不幸的是,您必须配置它们:
resilience4j.circuitbreaker:
configs:
default:
registerHealthIndicator: true
instances:
myCB:
baseConfig: default你可以说是个窃听器。
https://stackoverflow.com/questions/60528426
复制相似问题