Skip to content
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

A FutureLocal.java would be nice(like ThreadLocal.java but more) #17

Closed
deanorderly opened this issue May 31, 2020 · 1 comment
Closed

Comments

@deanorderly
Copy link

Twitter Futures allow swapping the slf4j MDC to use Local.scala which is a special context using a combination of ThreadLocal and swapping in/out context for thenCompose and thenApply. In this way, when a request comes in, I can MDC.put("userName", userName); and it will be available to all logging across all thenApply and thenCompose methods. Without this, logging in slf4j with MDC generally breaks down. With this fix, one can swap the MDC with a FutureLocal.java usage. Of course, the Futures will have to know about FutureLocal.java to make this happen.

@vsilaev
Copy link
Owner

vsilaev commented Jun 1, 2020

Please read the following section in docs:
"8. Context variables & contextual Promises"

The functionality will be altered in the upcoming release, but the idea will remain the same. So, in fact, it's possible to propagate ThreadLocals and alike contextual variables.

@vsilaev vsilaev closed this as completed Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants