I have a spring boot app, which uses resilience4j AOP-based @CircuitBreaker
s.
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.
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 @CircuitBreaker
s 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
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.