Skip to content

feat: add request ID middleware for request tracing#347

Open
shivv23 wants to merge 1 commit into
c2siorg:mainfrom
shivv23:feat/request-id-middleware
Open

feat: add request ID middleware for request tracing#347
shivv23 wants to merge 1 commit into
c2siorg:mainfrom
shivv23:feat/request-id-middleware

Conversation

@shivv23
Copy link
Copy Markdown
Contributor

@shivv23 shivv23 commented May 22, 2026

Summary

Add a RequestIDMiddleware that attaches a unique X-Request-ID header to every HTTP response. This enables request tracing across logs and client-side debugging.

Changes

  • app/middleware.py: Added RequestIDMiddleware — generates a UUID if none is provided, preserves client-sent IDs
  • app/main.py: Registered RequestIDMiddleware before RequestLoggingMiddleware
  • 4 new tests: validates header presence, UUID format, client value preservation, and uniqueness per request

Validation

  • 4 new unit tests added
  • Single commit, rebased on latest main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant