Skip to content

feat(observability): structured logging, metrics, tracing with correlation-id propagation #10

@MarkCesium

Description

@MarkCesium

Summary

Gateway is the correlation-id origin — every trace starts here. Right now logs are logging text, no /metrics, no OTel.

Changes

  • Correlation-id middleware: read X-Correlation-Id or generate uuid4(); stash in contextvars; attach to response header.
  • gRPC client interceptor injects x-correlation-id into metadata for every upstream call.
  • structlog JSON logs bound to correlation_id.
  • OpenTelemetry: opentelemetry-instrumentation-fastapi + opentelemetry-instrumentation-grpc (client side). OTLP export to the collector from infra#18.
  • Prometheus: gateway_http_request_duration_seconds{route,method,status}, per-upstream gRPC histogram, retry counter (feat(reliability): retry and circuit breaker for upstream gRPC #9).

Verification

  • curl -H 'X-Correlation-Id: test-123' /api/auth/me — response header echoes test-123; auth logs show correlation_id=test-123; trace visible in Tempo with HTTP root span and gRPC child spans.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions