jazzband / django-silk

Silky smooth profiling for Django
MIT License
4.32k stars 332 forks source link

Add api to access request_id of current request #689

Open erikcw opened 7 months ago

erikcw commented 7 months ago

It would be really nice to be able to fetch the request_id of the current request so that it can be added to a response header or otherwise "reported" during the request/response cycle to allow direct lookup in the Silk UI of a specific interaction (ie https://example.com/silk/request/3b9671bf-1dd0-4e02-97df-a5f39fb32480/).

Adding it to the request object (request.silk_request_id == '3b9671bf-1dd0-4e02-97df-a5f39fb32480') or adding a function which returns the ID for the current request (get_silk_request_id()) seem like reasonable approaches.

If this is already accessible through some other means, sorry for missing that. I looked through the docs and the code and it doesn't seem to be implemented currently.