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.
Summary
backend/auth/src/main.py:27-31useslogging.basicConfigwith a text format. No correlation across services, no metrics endpoint, no traces.Changes
loggingsetup withstructlogemitting JSON; bindcorrelation_id,user_id(when known),grpc_method.x-correlation-idfrom metadata, generate if missing, bind tostructlog.contextvars.AUTH__METRICS_PORTexposing/metricsviaprometheus-client.auth_grpc_request_duration_seconds{method}. Counters: login success/failure, OTP sends, revocation hits.Verification
docker compose logs authemits one JSON object per line.curl auth:9100/metricsreturns Prometheus exposition format.