Skip to content

feat: add request ID middleware and trace propagation (Closes #27) - #66

Open
ZacLou wants to merge 3 commits into
StellarRoute:mainfrom
ZacLou:feat/issue-27-request-id-middleware
Open

feat: add request ID middleware and trace propagation (Closes #27)#66
ZacLou wants to merge 3 commits into
StellarRoute:mainfrom
ZacLou:feat/issue-27-request-id-middleware

Conversation

@ZacLou

@ZacLou ZacLou commented Aug 28, 2026

Copy link
Copy Markdown

Closes #27

Changes

Adds request ID middleware for trace propagation across API and gateway services:

  • request_id middleware: Reads X-Request-Id header from incoming requests or generates a UUIDv4 if missing
  • Response header: Injects x-request-id into all responses for client-side correlation
  • Tracing span: Records request_id in the current tracing span for distributed trace propagation
  • Both services: Applied to API public router and gateway router

Files changed

  • crates/api/src/middleware.rs — Added request_id middleware function
  • crates/api/src/main.rs — Wired into public router as outermost layer
  • crates/gateway/src/routes.rs — Added inline request_id middleware, wired into gateway router

Behavior

  • Client sends X-Request-Id: abc-123 → echoed back in response, recorded in logs
  • Client omits header → server generates 550e8400-e29b-..., returned in response

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.

[gateway] Add request ID middleware and trace propagation

1 participant