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
Is it possible to hook/log requests at the start of the request? (aiohttp's AccessLogger is invoked after the request, as it receives the response as one of its arguments.)
As part of our logging, we'd like to assign each request a unique ID. Ideally the request comes in w/ this in a header, but if it doesn't, we assign it one. Currently, we do this in an AccessLogger, when we log there, however, this means this ID isn't associated w/ the request until the very end. I was wondering if it's possible to hook the very start of the request, s.t. this can happen as early as possible. This allows other logging calls that occur during the processing of the request to access this context. Essentially, I want to be able to know that "this log line indicating a DB call belongs to this request", which is made difficult when aiohttp handles multiple requests simultaneously, as the logs get intertwined. Hence, attaching an ID allows the log reader to understand which lines apply to which requests.
I can wrap every request handler in a decorator to accomplish this, but I was wondering if there was something more convenient.
The text was updated successfully, but these errors were encountered:
GitMate.io thinks the contributor most likely able to help you is @asvetlov.
Possibly related issues are #619 (Not possible to do requests with pre-compressed data), #669 (Log request process time in seconds), #875 (Improve Request.repr), #575 (how to log the incoming requests and the response), and #242 (Request's storage).
Long story short
Is it possible to hook/log requests at the start of the request? (
aiohttp
'sAccessLogger
is invoked after the request, as it receives the response as one of its arguments.)As part of our logging, we'd like to assign each request a unique ID. Ideally the request comes in w/ this in a header, but if it doesn't, we assign it one. Currently, we do this in an
AccessLogger
, when we log there, however, this means this ID isn't associated w/ the request until the very end. I was wondering if it's possible to hook the very start of the request, s.t. this can happen as early as possible. This allows other logging calls that occur during the processing of the request to access this context. Essentially, I want to be able to know that "this log line indicating a DB call belongs to this request", which is made difficult when aiohttp handles multiple requests simultaneously, as the logs get intertwined. Hence, attaching an ID allows the log reader to understand which lines apply to which requests.I can wrap every request handler in a decorator to accomplish this, but I was wondering if there was something more convenient.
The text was updated successfully, but these errors were encountered: