Skip to content

feat(backend): add request ID middleware for distributed tracing #47

Description

@GRACENOBLE

Problem

No correlation ID is generated or propagated. When a request fails it is impossible to correlate the client error with a specific backend log line, especially once Sentry and structured logs are both in play.

Expected behaviour

  • Every request gets a unique ID (UUID v4 or similar)
  • The ID is read from X-Request-ID if the caller provides one, otherwise generated
  • The ID is set on the Gin context and included in all log lines for that request
  • The ID is returned in the X-Request-ID response header

Acceptance criteria

  • New middleware in internal/transport/middleware/request_id.go
  • Middleware registered before the logger in routes.go
  • Logger middleware reads the ID from context and includes it in every log entry
  • Documented in backend/docs/

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: backendGo REST APIpriority: criticalMust fix immediately — production incident or blockertype: featureNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions