diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletApiAdvice.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletApiAdvice.java index b3a56e63d5..c52377be12 100644 --- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletApiAdvice.java +++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletApiAdvice.java @@ -55,7 +55,15 @@ public abstract class ServletApiAdvice { private static final DetachedThreadLocal servletPathTL = GlobalVariables.get(ServletApiAdvice.class, "servletPath", WeakConcurrent.buildThreadLocal()); private static final DetachedThreadLocal pathInfoTL = GlobalVariables.get(ServletApiAdvice.class, "pathInfo", WeakConcurrent.buildThreadLocal()); - private static final List requestExceptionAttributes = Arrays.asList("javax.servlet.error.exception", "jakarta.servlet.error.exception", "exception", "org.springframework.web.servlet.DispatcherServlet.EXCEPTION", "co.elastic.apm.exception"); + private static final String ELASTIC_EXCEPTION = "co.elastic.apm.exception"; + private static final String JAVAX_ERROR_EXCEPTION = "javax.servlet.error.exception"; + private static final String JAKARTA_ERROR_EXCEPTION = "jakarta.servlet.error.exception"; + private static final List requestExceptionAttributes = Arrays.asList( + JAVAX_ERROR_EXCEPTION, + JAKARTA_ERROR_EXCEPTION, + "exception", + "org.springframework.web.servlet.DispatcherServlet.EXCEPTION", + ELASTIC_EXCEPTION); @Nullable public static Object onServletEnter( @@ -233,7 +241,13 @@ public static getHeaderNames(HttpServletResponse httpServletResponse) { return httpServletResponse.getHeaderNames(); diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JavaxServletApiAdapter.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JavaxServletApiAdapter.java index 8d0e3b5fd0..585745afec 100644 --- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JavaxServletApiAdapter.java +++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JavaxServletApiAdapter.java @@ -256,6 +256,11 @@ public void setAttribute(HttpServletRequest servletRequest, String attributeName servletRequest.setAttribute(attributeName, value); } + @Override + public void removeAttribute(HttpServletRequest servletRequest, String attributeName) { + servletRequest.removeAttribute(attributeName); + } + @Override public Collection getHeaderNames(HttpServletResponse httpServletResponse) { return httpServletResponse.getHeaderNames(); diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/ServletRequestAdapter.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/ServletRequestAdapter.java index a60f170538..c13625c587 100644 --- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/ServletRequestAdapter.java +++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/ServletRequestAdapter.java @@ -90,6 +90,8 @@ public interface ServletRequestAdapter { void setAttribute(HttpServletRequest request, String attributeName, Object value); + void removeAttribute(HttpServletRequest request, String attributeName); + Map getParameterMap(HttpServletRequest httpServletRequest); TextHeaderGetter getRequestHeaderGetter();