简体   繁体   English

Java/Spring:如何找到打开 Resilence4J 断路器的错误?

[英]Java/Spring: How to find what error opened the Resilence4J circuit breaker?

I am using the Resilence4j circuit breaker with Spring Boot as shown below:我正在使用带有 Spring 引导的Resilence4j断路器,如下所示:

import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;

@Component
@CircuitBreaker(name = "ExternalService")
public class ExternalServiceClient implements APIClient {
     //....
}

I haven't specified any additional configs in my application.yml so the circuit breaker is operating with the default values.我没有在application.yml中指定任何其他配置,因此断路器使用默认值运行。 Whenever the breaker opens, I see errors like:每当断路器打开时,我都会看到如下错误:

Failure to call external service  for entity id 12343
   stack_trace: io.github.resilience4j.circuitbreaker.CallNotPermittedException: CircuitBreaker 'ExternalService' is OPEN and does not permit further calls
    at io.github.resilience4j.circuitbreaker.CallNotPermittedException.createCallNotPermittedException(CallNotPermittedException.java:37) ~[resilience4j-circuitbreaker-1.1.0.jar!/:1.1.0]
    at io.github.resilience4j.circuitbreaker.internal.CircuitBreakerStateMachine$HalfOpenState.acquirePermission(CircuitBreakerStateMachine.java:685)
    at io.github.resilience4j.circuitbreaker.internal.CircuitBreakerStateMachine.acquirePermission(CircuitBreakerStateMachine.java:146)
    at io.github.resilience4j.circuitbreaker.CircuitBreaker.lambda$decorateCheckedSupplier$82a9021a$1(CircuitBreaker.java:599)
    at io.github.resilience4j.circuitbreaker.CircuitBreaker.executeCheckedSupplier(CircuitBreaker.java:340)
    at io.github.resilience4j.circuitbreaker.configure.CircuitBreakerAspect.defaultHandling(CircuitBreakerAspect.java:155) ~[resilience4j-spring-0.16.0.jar!/:0.16.0]
    at io.github.resilience4j.circuitbreaker.configure.CircuitBreakerAspect.proceed(CircuitBreakerAspect.java:115)
    at io.github.resilience4j.circuitbreaker.configure.CircuitBreakerAspect.circuitBreakerAroundAdvice(CircuitBreakerAspect.java:98)
    at jdk.internal.reflect.GeneratedMethodAccessor238.invoke(Unknown Source) ~[na:na]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) ~[spring-aop-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)

This is telling me the breaker opened due to some error condition(and as a result no more calls are permitted) but doesn't specify what the original error was.这告诉我由于某些错误条件而打开了断路器(因此不允许再调用),但没有指定原始错误是什么。 Is there a way to figure out the original error?有没有办法找出原始错误? Is there specific text I should look for in the logs or is there some setting I need to turn on so this error also tells me the original reason for breaker opening?是否有我应该在日志中查找的特定文本,或者我需要打开一些设置,所以这个错误也告诉我断路器打开的原始原因?

CallNotPermittedException and the underlying stack trace occur within the state machine logic after the breaker is opened, this is not the right place to look. CallNotPermittedException 和底层堆栈跟踪发生在断路器打开后 state 机器逻辑中,这不是查看的正确位置。

The events consumer buffer exposed through the actuator endpoint /actuator/circuitbreakerevents would list all the events within the breaker, what are errors, and the corresponding message.通过执行器端点/actuator/circuitbreakerevents公开的事件消费者缓冲区将列出断路器内的所有事件、错误是什么以及相应的消息。

https://resilience4j.readme.io/docs/getting-started-3#events-endpoint https://resilience4j.readme.io/docs/getting-started-3#events-endpoint

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM