6

I have a spring boot app, which uses resilience4j AOP-based @CircuitBreakers.

Now I would like to make the circuit breakers' information available in the /actuator/health endpoint, but I'm not seeing the details.circuitBtreakers objects described in the docs in the JSON output.

What am I doing wrong?


By comparison, getting dynamic cache information to appear in the /actuator/metrics endpoint required a small amount of custom wiring, but this is well documented. I wonder if there is a similar trick that I can apply for dynamically defined @CircuitBreakers to be registerd with the /actuator/health endpoint.

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
Community
  • 1
  • 1
derabbink
  • 2,419
  • 1
  • 22
  • 47

1 Answers1

5

Dynamically registering CircuitBreakers for the HealthIndicator endpoint doesn't work at the moment. Unfortunately you have to configure them:

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

You could say it's a bug.

https://github.com/resilience4j/resilience4j/blob/master/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/health/CircuitBreakersHealthIndicator.java#L99-L102

Robert Winkler
  • 1,734
  • 9
  • 8
  • The docs (and your answer here) show how to configure them, but what are the endpoints? https:///actuator/health/circuitbreaker(s) is not working. I've guessed at a few other permutations but not successfully so far. – Geyser14 Aug 31 '20 at 16:08
  • ../actuator/health just shows status=OK, even though I have configured both management.health.circuitbreakers.enabled=true and resilience4j.circuitbreaker.configs.default.registerHealthIndicator=true – Geyser14 Aug 31 '20 at 16:14