Skip to content

[GSSoC26] feat: Add request ID middleware for API traceability#450

Open
ashrion wants to merge 1 commit into
Nsanjayboruds:mainfrom
ashrion:feat/request-id-middleware
Open

[GSSoC26] feat: Add request ID middleware for API traceability#450
ashrion wants to merge 1 commit into
Nsanjayboruds:mainfrom
ashrion:feat/request-id-middleware

Conversation

@ashrion

@ashrion ashrion commented Jul 11, 2026

Copy link
Copy Markdown

Description

This PR adds a request ID middleware to enable API request traceability.

Changes

  • Created backend/middleware/requestId.js middleware
  • Generates unique request ID for each incoming request
  • Attaches request ID to req.requestId for use in controllers
  • Adds X-Request-ID header to all responses
  • Accepts existing x-request-id header from clients for distributed tracing

Motivation

  • Enables request tracking across microservices and logs
  • Helps with debugging by correlating logs to specific requests
  • Supports distributed tracing when integrated with logging systems

Testing

  • Make a request to any API endpoint
  • Verify X-Request-ID header is present in response
  • Verify req.requestId is available in controllers
  • Send custom x-request-id header and verify it is echoed back

Closes #449

GSSoC26 contribution

- Create backend/middleware/requestId.js middleware
- Generate unique request ID for each request (or use existing x-request-id header)
- Attach requestId to req object and response header
- Add middleware to Express app in app.js

GSSoC26
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.

[GSSoC26] feat: Add request ID middleware for API traceability

1 participant