## 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 (https://github.com/PlaceBrain/gateway/issues/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.
Summary
Gateway is the correlation-id origin — every trace starts here. Right now logs are
loggingtext, no/metrics, no OTel.Changes
X-Correlation-Idor generateuuid4(); stash incontextvars; attach to response header.x-correlation-idinto metadata for every upstream call.structlogJSON logs bound to correlation_id.opentelemetry-instrumentation-fastapi+opentelemetry-instrumentation-grpc(client side). OTLP export to the collector from infra#18.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 echoestest-123; auth logs showcorrelation_id=test-123; trace visible in Tempo with HTTP root span and gRPC child spans.