Open uberjay opened 3 years ago
From the description of #162 it seems it was intended to preserve originally intended behavior. It should be possible to implement fiber contexts for MDC without affecting the original MDC feature. Perhaps a configuration option to be set to something other than default, or to have a different MDC class altogether.
I'm not sure if this project is maintained anymore but I vote that this is a good idea in principle. @uberjay
Unfortunately #162 broke diagnostic contexts for applications using Fibers. If you don't use fibers,
Thread.current#[]
resolves to "the current thread’s root fiber if not explicitly inside a Fiber" (from the Thread documentation).This means threaded code would have continued to function as expected, and fibered code also functions as expected. By changing to use
thread_variable_get
andthread_variable_set
, you've made it so diagnostic contexts only work in threaded code.I know this is basically ancient history, at this point, but I wonder if this change was fixing a bug that came up?
The following code demonstrates logging mdc from fiber and thread contexts. In 2.1.0 it works for either -- in 2.2.0 it only works for threads.
Output with 2.1.0:
Output with 2.2.0:
As you can see, in 2.2.0+ all of the fibers' log messages have a MDC['id'] value of
f003
, which is the most-recently created fiber id.Unfortunately, this means I'm stuck on logging 2.1.0, or maintaining a fork which reverts #162. I'm happy to submit a PR to revert it, but I'm concerned that it may have actually been fixing something. Any thoughts?