New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@SentinelDegrade注解不生效 #135
Comments
在对 @Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Method method = Objects.requireNonNull(request.tag(Invocation.class)).method();
SentinelDegrade sentinelDegrade = AnnotationExtendUtils.findMergedAnnotation(method, method.getDeclaringClass(),
SentinelDegrade.class);
if (!needDegrade(sentinelDegrade)) {
return chain.proceed(request);
}
String resourceName = parseResourceName(method);
Entry entry = null;
try {
entry = SphU.entry(resourceName, ResourceTypeConstants.COMMON_WEB, EntryType.OUT);
return chain.proceed(request);
} catch (BlockException e) {
throw new RetrofitBlockException(e);
} catch (IOException | RetrofitException ex) {
Tracer.traceEntry(ex, entry);
throw ex;
} finally {
if (entry != null) {
entry.exit();
}
}
} 5次异常,995次拦截。 通过上述的改动,可以使 @SentinelDegrade(grade = 2, count = 1)
@RetrofitClient(baseUrl = "https://api.com", connectTimeoutMs = 3000,
fallback = Fallback.class, fallbackFactory = FallbackFactory.class)
public interface TexSmartApi {
@Retry(intervalMs = 20)
@POST("api")
Response api(@Body Request request);
} 需要在方法调用地方对Retry Failed的 可以先进行2次重试,然后抛出Retry Failed的 |
厉害了,分析的很深入。我在 |
@chentianming11 升级到了2.3.10,测试可以熔断。👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
java.net.ConnectException
异常模拟调不通的情况,未触发ApiFallback中的代码,在Sentinel的${user_home}/logs/csp
日志目录中发现异常未计数:日志的第7个数值为异常数
SentinelRetrofitDegrade
类中未通过Tracer
对异常进行统计:Tracer
记录的代码:https://github.com/alibaba/Sentinel/blob/master/sentinel-adapter/sentinel-okhttp-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/okhttp/SentinelOkHttpInterceptor.java
The text was updated successfully, but these errors were encountered: