弹簧启动执行器运行状况端点+动态弹性4j断路器

问题描述 投票:1回答:1

我有一个Spring Boot应用程序,它使用基于AOP的resilience4j @CircuitBreaker

现在,我想使断路器的信息在@CircuitBreaker端点中可用,但在JSON输出中看不到/actuator/health对象details.circuitBtreakers

我在做什么错?


通过比较,要使动态缓存信息出现在described in the docs端点中,需要进行少量的自定义接线,但这是/actuator/metrics。我想知道是否有类似的技巧可以申请动态定义的well documented来向@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
java spring-boot spring-boot-actuator resilience4j
1个回答
0
投票

动态地为HealthIndicator端点注册CircuitBreakers目前不起作用。不幸的是,您必须配置它们:

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

您可以说这是一个错误。

resilience4j.circuitbreaker: configs: default: registerHealthIndicator: true instances: myCB: baseConfig: default

© www.soinside.com 2019 - 2024. All rights reserved.