Circuit breaker supports ignoring some exceptions

网关限流中,我抛出auth异常过多导致服务熔断,这个异常应该被忽略的

这个异常可以在我定义DegradeRule时被忽略

原提问者GitHub用户Lawrence-Albet

展开
收起
学习娃 2023-05-19 15:18:14 101 分享 版权
1 条回答
写回答
取消 提交回答
  • 您可以利用Tracer中的setExceptionsToIgnore来忽略一些异常:

    Sentinel/sentinel-core/src/main/java/com/alibaba/csp/sentinel/Tracer.java

    Lines 144 to 158 in 5ac112e

     /** 
      * Set exceptions to ignore. if not set, all Exception except for {@link BlockException} will be traced. 
      * <p> 
      * Note that if both {@link #setExceptionsToTrace(Class[])} and this method is set, 
      * the ExceptionsToIgnore will be of higher precedence. 
      * </p> 
      * 
      * @param ignoreClasses the list of exception classes to ignore. 
      * @since 1.6.1 
      */ 
     @SafeVarargs 
     public static void setExceptionsToIgnore(Class<? extends Throwable>... ignoreClasses) { 
         checkNotNull(ignoreClasses); 
         Tracer.ignoreClasses = ignoreClasses; 
     } 
    

    原回答者GitHub用户sczyh30

    2023-05-19 20:21:26
    赞同 展开评论
问答地址:

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

还有其他疑问?
咨询AI助理