Details
-
Question
-
Status: Closed
-
Minor
-
Resolution: Information Provided
-
2.10.0
-
None
-
None
Description
Hello, my team supports a spring boot rest API and we have been leveraging ThreadContext to share meta-data about our api requests to the log events we record throughout our request processing.
Recently we had noticed that logs generated from thread-pool or worker threads do not share this context and the contextMap would be empty.
For that reason we enabled
isThreadContextMapInheritable=true
This indeed shares the context to child threads, but now we are having an issue where the contextMap is bleeding into the logs of other API requests. Please advise how to better tune this functionality.
Below is a snippet of code where we build the ThreadContext in the API resource and attempt to clear it before another request comes in.
try { ThreadContext.put("id", request.getId()); <..more context..> return evaluate(request } finally { ThreadContext.clearAll(); }