Add Request ID to API Response Headers
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Motivation
API responses do not include the request ID in response headers, making it difficult for clients to correlate their requests with server-side logs for debugging purposes.
- Clients have no way to retrieve the request ID used for their request
- Support teams cannot easily link client-reported issues to server logs
## Required Features
- Add `X-BackendAI-RequestID` header to all API responses
- Implement via `on_response_prepare` hook in aiohttp application setup
- Apply to all components: Manager, App-Proxy Coordinator, App-Proxy Worker, Account Manager
- Read request ID from current context or request storage
## Impact
- `src/ai/backend/manager/server.py`
- `src/ai/backend/appproxy/coordinator/server.py`
- `src/ai/backend/appproxy/worker/server.py`
- `src/ai/backend/account_manager/server.py`
- Common middleware in `src/ai/backend/common/middlewares/`
## Testing Scenarios
- Verify all API responses include `X-BackendAI-RequestID` header
- Verify header value matches the request ID used in server logs
- Test with both provided and auto-generated request IDs
JIRA Issue: BA-3723
Contributor guide
Assessment
This issue has not been assessed yet.