Web过滤器,如果servlet没有抛出外部,则统计信息不会异常

如题

@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest sRequest = (HttpServletRequest)request;

    Entry entry = null;
    try {
        ContextUtil.enter(WebServletConfig.WEB_SERVLET_CONTEXT_NAME);
        entry = SphU.entry(TOTAL_URL_REQUEST, ResourceTypeConstants.COMMON_WEB, EntryType.IN);
        chain.doFilter(request, response);
    } catch (BlockException e) {
        HttpServletResponse sResponse = (HttpServletResponse)response;
        WebCallbackManager.getUrlBlockHandler().blocked(sRequest, sResponse, e);
    } catch (IOException | ServletException | RuntimeException e2) {
        Tracer.trace(e2);
        throw e2;
    } finally {
        if (entry != null) {
            entry.exit();
        }
        ContextUtil.exit();
    }
}

可能永远都不会执行Tracer.trace(e2); 这样的话根据异常来降级就不生效吧

原提问者GitHub用户whaon

展开
收起
码字王 2023-05-19 17:04:22 98 分享 版权
1 条回答
写回答
取消 提交回答
  • 可以参考这个:https://github.com/alibaba/Sentinel/wiki/FAQ

    原回答者GitHub用户sczyh30

    2023-05-19 21:15:28
    赞同 展开评论