-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy MDC context in workspace runtime (start stop) related async tasks #8585
Conversation
I would say we need to solve this task a bit more general. My proposal is to create two classes
|
@skabashnyuk can you explain "more general" ? I don't see which improvements will bring your suggestions and feel like it is adding more complexity. |
As far as I understand the problem that MDC context is lost when one thread delegates some work to another with help of ThreadLocalPropagateContext. And you are fixed it in one particular place WorkspaceRuntimes. |
+1 to use it in all the places ThreadLocalPropagateContext is used as @skabashnyuk suggested |
@skabashnyuk OK thanks, understand works for me |
bf69744
to
e7a85a4
Compare
…ropagateContext.wrap method Signed-off-by: Sun Tan <sutan@redhat.com>
e7a85a4
to
0f6fe41
Compare
@skabashnyuk @garagatyi I've updated the PR as requested, let me know if it works for you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello.
Close but not exactly what I thought.
The idea was to consider ThreadLocalPropagateContext as a framework that is propagating thread-local variables to any child Threads. I was expecting to see
something very similar to EnvironmentContext(EnvironmentContextFilter). But in your case, you are modifying
framework itself by adding a direct dependency on slf4j.
But I saw recommendation https://logback.qos.ch/manual/mdc.html#managedThreads and don't mind if you merge it as is.
BTW. I haven't seen in our filters a place where we reset MDC. Are you using MDCInsertingServletFilter in some place?
@skabashnyuk Yes, I will keep like that because MDC is using a mechanism similar to thread local but which is not thread local so it won't make sense (and may have strange behaviour) to mix the two of them. Could you approve this PR ? |
What does this PR do?
When MDC is used in Che log configuration, we figured out that some information were not passed through workspace start and stop tasks. These tasks were executed asynchronously to different thread pools.
This PR is fixing the issue by copying the context. It uses kind of the same mechanism that has been used for thread local in the same portion of code.
What issues does this PR fix or reference?
redhat-developer/rh-che#495