bootique / bootique-jetty

Provides Jetty integration with Bootique

Home Page:https://bootique.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Centralized MDC management service

andrus opened this issue · comments

Currently we have 2 MDC producers (TransactionIdMDC in bootique-metrics and PrincipalMDC in bootique-shiro). Each has their own handler implemented as ServletRequestListener, and each one has to deal with issues like premature MDC cleanup (they do it differently - PrincipalMDC is reset at the end of the request, while TransactionIdMDC is reset in the beginning of the following request, resulting in leaking TX id to the unrelated threads (and I wonder if #84 is also caused by failure to clear state).

Per this task we are going to create a centralized Jetty request MDC manager that will all registering individual handlers that will be initialized and cleaned up at the same time. Also we may take a shot at expanding request MDC scope beyond ServletRequestListener by using Jetty HttpChannel.Listener instead, and without exposing this private Jetty API to the users.

Done. The redesign fixes two outstanding issues:

  • leak of TransactionIdMDC
  • missing PrincipalMDC in the request log line (last line in a request log generated by the RequestLogger)