{"repo":"messa/aiohttp-request-id-logging","free":true,"listed":false,"github":"https://github.com/messa/aiohttp-request-id-logging","clone":"git clone https://github.com/messa/aiohttp-request-id-logging.git","description":"Add [request id] to Python logging records for the Aiohttp server.","language":"Python","stars":12,"topics":["aiohttp","aiohttp-server","logging","python-logging","python3","request-id","correlation-id","sentry"],"license":"MIT","category":"analytics","readme_excerpt":"aiohttp-request-id-logging ========================== Motivation ---------- When logging from an async application (e.g. aiohttp web application), log messages from different async tasks, http requests etc. are intertwined and you cannot surely tell which line was generated by what request. For example: So, which transfer has failed? The one with id 1234, or the one with id 5678? Of course, ideally the error message should contain also the transfer id. But it is not always this case, or you may want to inspect also other log messages that were logged by that specific task/request. When you start to use this library in your aiohttp web application, this is how your log messages will look like: Installation ------------ The library is available on PyPI: aiohttp-request-id-logging Usage ----- For more complete example see examples/demo.py. Customization of the middleware behavior is demonstrated in examples/demo customization injection.py (constructor parameters) and examples/demo customization subclassing.py (subclassing). How it works ------------ This library helps you to add request (correlation) id to the log messages in a few steps: 1. RequestIdMiddleware : Generate random request id for each aiohttp request and - store it in a ContextVar aiohttp request id logging.request id - store it also in the request storage: request[aiohttp request id logging.REQUEST ID KEY] (and, by default, also under the plain string key request['request id'] for backward compatibility) - return ","default_branch":null,"files":null,"tree":[],"storefront":"/r/messa","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/messa/aiohttp-request-id-logging/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}