You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking to use asyncio debug mode to understand some issues with blocked event loops. The way that ddtrace patches asyncio leads to the name of each coroutine being masked.
Here's an example of the logs I get out without ddtrace:
Executing <Task finished name='Task-1' coro=<my_function() done, defined at /app/src/block.py:5> result=None created at /usr/lib64/python3.12/asyncio/runners.py:100> took 2.002 seconds
And with ddtrace-run:
Executing <Task finished name='Task-1' coro=<_wrapped_create_task_py37.<locals>.traced_coro() done, defined at /usr/local/lib64/python3.12/site-packages/ddtrace/contrib/asyncio/patch.py:47> result=None created at /usr/local/lib64/python3.12/site-packages/ddtrace/contrib/asyncio/patch.py:53> took 2.008 seconds
Note the _wrapped_create_task_py37.<locals>.traced_coro() is really unhelpful here, and I'd much rather see the reference to the original function.
Here's the minimal example:
test.py:
async def my_function():
time.sleep(2)
if __name__ == "__main__":
asyncio.run(my_function())
Run with: PYTHONASYNCIODEBUG=1 ddtrace-run python3 test.py.
The text was updated successfully, but these errors were encountered:
I see that you're using python3.12. Do you know if your application is setting an asyncio task factory or using the default eager-task-factory (ie: does this assertion pass: task_factory = asyncio.get_event_loop().get_task_factory(); assert task_factory is None and PY_VERSION >= (3, 12) or task_factory is asyncio.eager_task_factory). If this assertion passes then you can safely disable the asyncio integration by setting the following environment variable: DD_TRACE_ASYNCIO_ENABLED=False
Context
The asyncio integration ensures trace info is propagated when an asyncio task is created. When this integration is disabled trace info will always be propagated when the task is executed. In python3.12 asyncio tasks begin execution when a task is constructed (this is the default behavior but it can be overridden).
Next Steps
I opened a fix to ensure the name of coroutine is not overwritten by ddtrace. However the filename in created at and will still reference ddtrace but defined at should reference the original source.
I'm looking to use asyncio debug mode to understand some issues with blocked event loops. The way that ddtrace patches asyncio leads to the name of each coroutine being masked.
Here's an example of the logs I get out without ddtrace:
And with ddtrace-run:
Note the
_wrapped_create_task_py37.<locals>.traced_coro()
is really unhelpful here, and I'd much rather see the reference to the original function.Here's the minimal example:
test.py:
Run with:
PYTHONASYNCIODEBUG=1 ddtrace-run python3 test.py
.The text was updated successfully, but these errors were encountered: