-
Notifications
You must be signed in to change notification settings - Fork 876
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
Add context propagation support for direct Thread creation #2527
Comments
this will make our context leaking problems worse... |
I'm wondering whether this issue will gain importance with the arrival of virtual threads? Prior to virtual threads, it was more of an antipattern to use This changes now with virtual threads. It might become more common do the following:
At the same time, the
Do you have any opinions here? |
We might actually need to modify the For the direct |
We've been thinking about the same thing with the elastic APM agent. However, even with virtual threads the point against it about context leakage remains: An option we considered is to provide an instrumentation for
This gives users the choice, but it still is difficult to come up with a reasonable default. |
Aren't virtual threads supposed to be used for short-lived tasks though? If you start a new virtual thread for the purpose of handling HTTP connections that seems to kinda defeat the purpose (you could use a standard thread pool instead after all). Anyway, you've a good point though -- perhaps we should just wait a bit and see what usage patterns emerge after a while? |
To my understanding virtual threads are not limited to short-lived tasks. Short-lived tasks are just the key selling point for virtual threads where platform threads previously couldn't be used. From a Java user perspective, the only remaining benefit of platform threads is fairness in case of CPU-contention: Your platform thread is guaranteed to run at some point in time due to preemption of platform threads. Virtual threads in contrast can hog the CPU if they never finish and never block, causing other virtual threads to never run. I would however say that this is not your typical usage scenario in an HTTP server. Maybe a service receiving message from multiple message sources / queues is a better example:
Yeah I'm feeling the same way. |
We support context propagation when Runnable or Callable is submitted for execution to some executor service. But this does not work with the most primitive way to dispatch a unit of work into a separate thread:
new Thread(Runnable).start()
. Should add this instrumentation as well.The text was updated successfully, but these errors were encountered: