Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Component
public class MDCFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
MDC.put("tracking", request.getHeader("tracking-header"));
try {
filterChain.doFilter(request, response);
} finally {
MDC.clear();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment