我所做的是编写自己的 CustomAppstatsFilter 并排除某些 url。
public class CustomAppstatsFilter extends AppstatsFilter {
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
if (request instanceof HttpServletRequest) {
String url = ((HttpServletRequest) request).getRequestURL().toString();
// We do not want these to show up in appstats
if ((url.contains("appstats"))
|| url.contains("_ah/")
|| url.contains("cron/")
|| url.contains("batch/")) {
chain.doFilter(request, response);
return;
} else {
super.doFilter(request, response, chain);
}
}
}
}
编辑 - 这可以与 ZiglioNZ 很好的答案结合使用。
<!-- Appstats filter for profiling application -->
<filter>
<filter-name>appstats</filter-name>
<filter-class>my.company.filter.CustomAppstatsFilter</filter-class>
<init-param>
<param-name>maxLinesOfStackTrace</param-name>
<param-value>5</param-value>
</init-param>
</filter>
<filter-mapping>
<!-- excludes are in CustomAppstatsFilter -->
<filter-name>appstats</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>