Currently, with-log-context has the "magical" property of inheriting the dynamic MDC data tracked via Clojure and there's no way to start with a fresh context in a thread because of this. In addition, NDC is not inherited so there's an imbalance here.
It would make sense to separate the inheritance from the addition (in both cases) so that you could explicitly inherit the context if you wanted to (without adding to it), or you could create fresh context in a new thread.
I haven't really figured out the best way to handled NDC but tracking a stack of tags in a dyn var and having the (new) with-log-inherited (or whatever) pull in both the dyn MDC and dyn NDC would probably make sense.
Currently,
with-log-context
has the "magical" property of inheriting the dynamic MDC data tracked via Clojure and there's no way to start with a fresh context in a thread because of this. In addition, NDC is not inherited so there's an imbalance here.It would make sense to separate the inheritance from the addition (in both cases) so that you could explicitly inherit the context if you wanted to (without adding to it), or you could create fresh context in a new thread.
I haven't really figured out the best way to handled NDC but tracking a stack of tags in a dyn var and having the (new)
with-log-inherited
(or whatever) pull in both the dyn MDC and dyn NDC would probably make sense.See https://clojurians.slack.com/archives/C03S1KBA2/p1725576598725529?thread_ts=1724197490.093309&cid=C03S1KBA2 onward in the Slack thread for more background.