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
{{ message }}
Repository navigation
aiohttp integration ability to use contextvars in logger #670
Python documentation on Tasks here. One important thing is that they reset contextvars.
To summarize:
aiohttp logging exception
+ ^
| |
| asyncio.create_task(handle_request()) | contextvars didn't go up again
| | (it's fixed now)
| |
v |
Sentry |
+ |
| |
| asyncio.create_task(handle_request()) | contextvars don't go up
| |
v |
I set contextvars +---------------------+
Exception
As long as the issue is not fixed in Sentry, I still can't use contextvars to log custom data using the standard Python logging library.
The only solution is to disable Sentry, then logging works OK with contextvars.
Any idea how to fix this in Sentry-aiohttp code?
I'd be happy to open a PR, but I'm not familiar enough with Sentry code, or Python in general, thus I need some help at least.
I see, it seems the double-task thing may not be necessary at all assuming all aiohttp versions we care about already create a task. I would be fine with a PR that does not wrap anything in a task at all. This is very likely just cargo-culted from the Sanic integration.
Activity
untitaker commentedon Apr 18, 2020
I see, it seems the double-task thing may not be necessary at all assuming all aiohttp versions we care about already create a task. I would be fine with a PR that does not wrap anything in a task at all. This is very likely just cargo-culted from the Sanic integration.
H--o-l commentedon Apr 20, 2020
Hi @untitaker
Thanks for your quick answer.
I open a PR which does, I think, what you proposed: #674
fix: Preserve contextvars in aiohttp integration (#674)