Skip to content

feat(observability): structured logging, metrics, tracing #10

@MarkCesium

Description

@MarkCesium

Summary

backend/auth/src/main.py:27-31 uses logging.basicConfig with a text format. No correlation across services, no metrics endpoint, no traces.

Changes

  • Replace logging setup with structlog emitting JSON; bind correlation_id, user_id (when known), grpc_method.
  • gRPC server interceptor: read x-correlation-id from metadata, generate if missing, bind to structlog.contextvars.
  • Add a sidecar HTTP server on AUTH__METRICS_PORT exposing /metrics via prometheus-client.
  • Instrument gRPC server + SQLAlchemy + Redis with OpenTelemetry auto-instrumentation; export OTLP to the collector from infra#18.
  • Histograms: auth_grpc_request_duration_seconds{method}. Counters: login success/failure, OTP sends, revocation hits.

Verification

  • docker compose logs auth emits one JSON object per line.
  • curl auth:9100/metrics returns Prometheus exposition format.
  • A login request from gateway produces a span chain visible in Tempo/Jaeger with the gateway parent span.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions