Search code examples
pythonquart

Modifying quart.request - acceptable? (Python API)


I need to store some per-request metrics and telemetry (such as timestamps, etc) in quart (the python web framework). Is it acceptable behaviour to modify quart.request and add variables?

It appears to work, and it's similar to how I would have done it in Flask but I'm not sure if it is considered bad practice in Quart.

The background is that I want to store fine-grained telemetry (namely time stamps for when certain things happen inside a request) and not just the total request time.

Regards, Niklas


Solution

  • Yea, best to extend the Request class and then assign this new class to the request_class attribute on the app object