Hi everyone!
I made a small Django middleware called django-xbench because I kept running into the same question
When a request feels slow, is it slow because of the database or because of application logic and serialization
I use Django Debug Toolbar a lot for local debugging and it works really well.
But in staging or when doing quick checks on production Debug Toolbar is usually not enabled and full APM tools feel a bit heavy when I only want a simple timing signal
So I built something very lightweight
It measures total request time and DB time using connection.execute_wrapper
Then it calculates app time and exposes the result using Server-Timing response headers
This lets me check timing from browser DevTools or simple HTTP clients without setting up a big monitoring stack
Right now it supports
- total DB and app time split
- query count
- Server-Timing header output
- very simple setup with just one middleware
I would really appreciate feedback on a couple of things
1 Are there common issues with Server-Timing headers in real projects like proxies caching or security
2 Does putting this logic in middleware make sense or is there a better place to hook this kind of measurement
I’m still learning and would really appreciate any feedback
Thanks for reading and I am happy to improve this based on your feedback