fix: structog instead of logging, also updated middlewares
Merged
HA
8mo ago+921+921+012345678901234567890123456789-2318-2318-0123456789012345678901234567890123456789
Summary by cubic
Switched backend to structlog and OpenTelemetry tracing with a single OTLP traces endpoint and tail sampling. Removed correlation IDs across APIs, events, and storage; request size limits remain enforced by RequestSizeLimitMiddleware using MAX_REQUEST_SIZE_MB.
-
Refactors
- Replaced logging.Logger with structlog BoundLogger; logs bind OTEL span context, sanitize sensitive data, and use key=value fields.
- Removed CorrelationMiddleware and all correlation_id usage; events link via aggregate_id; replays use replay_id with updated indexes, models, and responses.
- Added a DI-managed Tracer (app/core/tracing/tracer.py) initialized from Settings; instruments httpx/pymongo/logging with ParentBased + TraceIdRatioBased sampling; removed custom tracing/adaptive sampling code.
- Providers inject BoundLogger and Tracer; services/workers no longer initialize tracing.
- Settings/CORS: dropped ENABLE_TRACING/Jaeger fields; added OTLP_TRACES_ENDPOINT; stopped exposing X-Correlation-ID and X-Request-ID.
- Updated otel-collector to include tail_sampling (error, slow, probabilistic) in the traces pipeline.
- Pod monitor config is provided via DI with defaults (namespace=integr8scode, kubeconfig_path=None).
- Reverted request size enforcement to RequestSizeLimitMiddleware (dependency approach removed).
-
Migration
- Set OTLP_TRACES_ENDPOINT and deploy the updated otel-collector with tail sampling.
- Stop sending/expecting X-Correlation-ID and X-Request-ID; rely on OTEL trace context.
- Update any dashboards/parsers that used correlation_id (events, indexes, exports, user settings, pod labels) to use aggregate_id or replay_id.
- Configure MAX_REQUEST_SIZE_MB as needed; enforcement is via RequestSizeLimitMiddleware.
- If pod monitoring relied on K8S_NAMESPACE/KUBECONFIG env vars, adjust deployment or provider configuration to the new defaults.
Summary by CodeRabbit
-
New Features
- Structured logging rolled out for clearer, consistent logs.
- Trace collector tail-sampling added to reduce noise (focus on error/slow traces).
-
Configuration Changes
- Tracing config simplified to a single OTLP endpoint.
-
Refactor
- Correlation ID removed across UI, filters, exports and APIs; replay_id introduced for replay flows and shown in replay responses.