Add structured request logging and trace propagation for backend observability
- Dominant language
- Python
- Stars
- 451
- Forks
- 702
- Avg merge
- 22h 59m
- Merged PRs (30d)
- 91
Description
**Is your feature request related to a problem? Please describe.**
Backend logs currently have limited request-level context, making it more difficult to correlate application events, troubleshoot issues, and trace requests across services.
**Describe the solution you'd like**
Introduce structured request logging and request correlation support by:
* Adding a Django request logging middleware.
* Capturing request metadata such as:
* request_id
* trace_id
* request method
* request path
* service
* environment
* Adding a logging filter to inject request context into log records.
* Outputting logs in structured JSON format.
* Propagating identifiers back to clients through:
* `X-Request-ID`
* `X-Trace-ID`
**Describe alternatives you've considered**
An alternative would be relying solely on external observability tooling. However, adding request context directly into application logs provides immediate value and improves compatibility with centralized logging and monitoring platforms.
**Are you going to work on implementing this?**
* [x] Yes
**Additional context**
A working implementation has already been prepared and tested on a fork.
Files involved:
* backend/apps/common/middlewares/request_logging.py
* backend/settings/base.py
The implementation supports request correlation, structured logging, and trace propagation, which aligns with observability and monitoring goals.
Contributor guide
Assessment
This issue has not been assessed yet.