Async Support for the threading Local Request store #779
Labels
api: logging
Issues related to the googleapis/python-logging API.
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: question
Request for information or clarification. Not an issue.
At this moment the code in https://github.com/googleapis/python-logging/blob/main/google/cloud/logging_v2/handlers/middleware/request.py uses a threading.Local to store the latest request for usage with the structured Logging.
This global singleton approach does not seem safe for Async Code, where one would either rather use contextvars library, or even easier for the current codebase do something along this:
Sidenote: every code I see using this technique imports threading on top anyway, I am not sure if this has some deeper significance, so I omitted it.
I do think, that to support async correctly in newer Django Versions, this change should be made, or it might ending up sending wrong logs in certain situations.
The text was updated successfully, but these errors were encountered: