Summary
- Log every request with method, path, client_ip, status, and latency_ms via tower-http TraceLayer
- Client IP extracted from x-forwarded-for / x-real-ip / socket addr — enables tracing requests across LB, gatekeeper, and PDS
- Set GATEKEEPER_LOG_FORMAT=json for JSON structured logs; default stays human-readable
Example output
Default: INFO request{method=POST path=/xrpc/com.atproto.server.createSession client_ip=148.251.49.115}: response status=200 latency_ms=42
JSON (GATEKEEPER_LOG_FORMAT=json): {"timestamp":"...","level":"INFO","span":{"method":"POST","path":"/xrpc/com.atproto.server.createSession","client_ip":"148.251.49.115"},"fields":{"status":200,"latency_ms":42}}
Test plan
- cargo test — all 26 tests pass
- Manual: start server, hit endpoints, verify logs show IP/method/path/status/latency
- Manual: set GATEKEEPER_LOG_FORMAT=json, verify JSON output