mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
calculate exception ratio in Sentinel RestTemplate
This commit is contained in:
parent
89178bc913
commit
ba101f479e
@ -33,6 +33,7 @@ import org.springframework.util.ClassUtils;
|
||||
|
||||
import com.alibaba.csp.sentinel.Entry;
|
||||
import com.alibaba.csp.sentinel.SphU;
|
||||
import com.alibaba.csp.sentinel.Tracer;
|
||||
import com.alibaba.csp.sentinel.context.ContextUtil;
|
||||
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
||||
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
|
||||
@ -69,16 +70,24 @@ public class SentinelProtectInterceptor implements ClientHttpRequestInterceptor
|
||||
hostEntry = SphU.entry(hostResource);
|
||||
response = execution.execute(request, body);
|
||||
}
|
||||
catch (BlockException e) {
|
||||
catch (Throwable e) {
|
||||
if (!BlockException.isBlockException(e)) {
|
||||
Tracer.trace(e);
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
return handleBlockException(request, body, execution, e);
|
||||
return handleBlockException(request, body, execution,
|
||||
(BlockException) e);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (ex instanceof IllegalStateException) {
|
||||
throw (IllegalStateException) ex;
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"sentinel handle BlockException error: " + ex.getMessage(), ex);
|
||||
"sentinel handle BlockException error: " + ex.getMessage(),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
Loading…
x
Reference in New Issue
Block a user