Open 24kpure opened 1 year ago
com.alibaba.csp.sentinel.adapter.spring.webmvc.AbstractSentinelInterceptor#preHandle
感觉不到业务异常,我通过degraderRule配置了异常num,但是没有用。
你是不是使用里全局异常处理器?如果使用了全局异常处理器那么异常会被处理器拦截导致AbstractSentinelInterceptor拦截器无法获取到异常信息。
Nowadays,does it exist that webapplication runs without globalExceptionHandler
? I try to extend SentinelWebInterceptor
and override mehtod traceExceptionAndExit
and make exception visible for sentinel, at last ,it works.
如今,是否存在 webapplication 运行时没有
globalExceptionHandler
?我尝试扩展SentinelWebInterceptor
和覆盖 mehtodtraceExceptionAndExit
并使异常对哨兵可见,最后,它起作用了。
可以发一下你重写的SentinelWebInterceptor的代码吗?让我参考一下。谢谢
protected void traceExceptionAndExit(Entry entry, Exception ex) {
if (entry == null) {
return;
}
if (ex == null) {
HttpServletRequest httpServletRequest = SerialNoUtils.getHttpServletRequest();
if (httpServletRequest == null) {
return;
}
// you have to make exception visible for sentinel, my plan is quite simple,just put it into request.
ex = (Exception) httpServletRequest.getAttribute(requestRefExceptionName);
}
if (ex != null) {
Tracer.traceEntry(ex, entry);
}
entry.exit();
}
com.alibaba.csp.sentinel.adapter.spring.webmvc.AbstractSentinelInterceptor#preHandle
can't feel business exception, I config exception num by degradeRule,but it doesn't work.