diff --git a/sentinel-adapter/sentinel-web-servlet/src/main/java/com/alibaba/csp/sentinel/adapter/servlet/CommonFilter.java b/sentinel-adapter/sentinel-web-servlet/src/main/java/com/alibaba/csp/sentinel/adapter/servlet/CommonFilter.java index bb8f5624..e246e06c 100755 --- a/sentinel-adapter/sentinel-web-servlet/src/main/java/com/alibaba/csp/sentinel/adapter/servlet/CommonFilter.java +++ b/sentinel-adapter/sentinel-web-servlet/src/main/java/com/alibaba/csp/sentinel/adapter/servlet/CommonFilter.java @@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse; import com.alibaba.csp.sentinel.Entry; import com.alibaba.csp.sentinel.EntryType; +import com.alibaba.csp.sentinel.ResourceTypeConstants; import com.alibaba.csp.sentinel.SphU; import com.alibaba.csp.sentinel.Tracer; import com.alibaba.csp.sentinel.adapter.servlet.callback.RequestOriginParser; @@ -79,7 +80,6 @@ public class CommonFilter implements Filter { throws IOException, ServletException { HttpServletRequest sRequest = (HttpServletRequest) request; Entry urlEntry = null; - Entry httpMethodUrlEntry = null; try { String target = FilterUtil.filterTarget(sRequest); @@ -98,11 +98,13 @@ public class CommonFilter implements Filter { String origin = parseOrigin(sRequest); String contextName = webContextUnify ? WebServletConfig.WEB_SERVLET_CONTEXT_NAME : target; ContextUtil.enter(contextName, origin); - urlEntry = SphU.entry(target, EntryType.IN); - // Add method specification if necessary + if (httpMethodSpecify) { - httpMethodUrlEntry = SphU.entry(sRequest.getMethod().toUpperCase() + COLON + target, - EntryType.IN); + // Add HTTP method prefix if necessary. + String pathWithHttpMethod = sRequest.getMethod().toUpperCase() + COLON + target; + urlEntry = SphU.entry(pathWithHttpMethod, ResourceTypeConstants.COMMON_WEB, EntryType.IN); + } else { + urlEntry = SphU.entry(target, ResourceTypeConstants.COMMON_WEB, EntryType.IN); } } chain.doFilter(request, response); @@ -112,12 +114,8 @@ public class CommonFilter implements Filter { WebCallbackManager.getUrlBlockHandler().blocked(sRequest, sResponse, e); } catch (IOException | ServletException | RuntimeException e2) { Tracer.traceEntry(e2, urlEntry); - Tracer.traceEntry(e2, httpMethodUrlEntry); throw e2; } finally { - if (httpMethodUrlEntry != null) { - httpMethodUrlEntry.exit(); - } if (urlEntry != null) { urlEntry.exit(); } diff --git a/sentinel-adapter/sentinel-web-servlet/src/main/java/com/alibaba/csp/sentinel/adapter/servlet/CommonTotalFilter.java b/sentinel-adapter/sentinel-web-servlet/src/main/java/com/alibaba/csp/sentinel/adapter/servlet/CommonTotalFilter.java index 4adf1bef..47161e0f 100755 --- a/sentinel-adapter/sentinel-web-servlet/src/main/java/com/alibaba/csp/sentinel/adapter/servlet/CommonTotalFilter.java +++ b/sentinel-adapter/sentinel-web-servlet/src/main/java/com/alibaba/csp/sentinel/adapter/servlet/CommonTotalFilter.java @@ -27,11 +27,11 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.alibaba.csp.sentinel.Entry; +import com.alibaba.csp.sentinel.ResourceTypeConstants; import com.alibaba.csp.sentinel.SphU; import com.alibaba.csp.sentinel.Tracer; import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager; import com.alibaba.csp.sentinel.adapter.servlet.config.WebServletConfig; -import com.alibaba.csp.sentinel.adapter.servlet.util.FilterUtil; import com.alibaba.csp.sentinel.context.ContextUtil; import com.alibaba.csp.sentinel.slots.block.BlockException; @@ -57,7 +57,7 @@ public class CommonTotalFilter implements Filter { Entry entry = null; try { ContextUtil.enter(WebServletConfig.WEB_SERVLET_CONTEXT_NAME); - entry = SphU.entry(TOTAL_URL_REQUEST); + entry = SphU.entry(TOTAL_URL_REQUEST, ResourceTypeConstants.COMMON_WEB); chain.doFilter(request, response); } catch (BlockException e) { HttpServletResponse sResponse = (HttpServletResponse)response;