Skip to content

Instantly share code, notes, and snippets.

@NutterzUK
Created October 26, 2020 21:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NutterzUK/09292525c3d19f3096b321f697dea83e to your computer and use it in GitHub Desktop.
Save NutterzUK/09292525c3d19f3096b321f697dea83e to your computer and use it in GitHub Desktop.
@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