Skip to content

Request Correlation IDs #73

Description

@nursetechie

Issue #33 — refactor: Request Correlation IDs

Description

In a microservices or complex backend environment, tracing an error through logs is extremely difficult if requests cannot be distinguished. Attaching a unique Correlation ID to every request allows developers to filter structured logs seamlessly, drastically reducing debugging time.


Requirements & Context

Architectural Goal: Improve system observability and debugging.

Implementation Expectations: Implement Express middleware that generates a uuid or reads X-Correlation-ID headers. Attach it to req.id. Ensure the centralized error handler outputs this ID to the client and the logs.


Acceptance Criteria

  • Every log line associated with a specific request shares the exact same Correlation ID.
  • The client receives the ID in error responses for support ticketing.

Out of Scope

  • Distributed tracing spans (e.g., OpenTelemetry setups).

Suggested Execution

git checkout -b refactor/correlation-ids

Suggested Commit Message

refactor: implement request correlation ids for traceability

Testing Notes

  • Trigger an API error and verify the Correlation ID exists in both the HTTP response and the server logs.

References

Best practices for Node.js logging and traceability.


Definition of Done

  • Ready for review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions