- Notifications
You must be signed in to change notification settings - Fork 231
Support capturing spans from code run in an event loop executor #705
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
Conversation
To make the current transaction/span available, we wrap the actual callable with one of our own that sets the transaction/span in the execution context of the thread.
| ||
class RunInExecutorInstrumentation(AsyncAbstractInstrumentedModule): | ||
name = "executor" | ||
instrument_list = [("asyncio.base_events", "BaseEventLoop.run_in_executor")] |
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.
Might we worth checking if this would also work with uvloop (https://github.com/MagicStack/uvloop/blob/8beacd265651429a558d1b22e200d6d81016f1db/uvloop/loop.pyx#L2646), but I have my doubts, as wrapt can't patch objects defined in C AFAIK
💔 Tests Failed
Expand to view the summary
Build stats
Test stats 🧪
Test errors Expand to view the tests failures> Show only the first 10 test failures |
f52f054
to ba881c6
Compare
What does this pull request do?
To make the current transaction/span available, we wrap the actual
callable with one of our own that sets the transaction/span in the
execution context of the thread.
Why is it important?
Using an executor (e.g. ThreadPoolExecutor) is a common way to use
blocking calls in an event loop.