feat(observability): add dual local logging sinks and static environment context
Why:
- Wanted human-readable console output while developing locally, without
losing a machine-parseable log for later grepping/parsing. A single
renderer chosen by a flag can't do both at once.
- ADR-0011 had no way to correlate an issue with a specific deployment
(build/region/instance) independent of any one request.
Changes:
- configure_logging() now builds two independent handlers: console (always
on, colored unless LOG_JSON_FORMAT=true) and an optional rotating JSON file
(LOG_FILE_PATH, unset by default) -- the same structlog event fans out to
both, so call sites are unaffected.
- A static structlog processor binds env/service_version onto every event.
Deliberately not a contextvar: RequestIdMiddleware's clear_contextvars()
would wipe a value bound there before the first request.
- New settings: APP_SERVICE_VERSION, LOG_FILE_PATH/LOG_FILE_MAX_BYTES/
LOG_FILE_BACKUP_COUNT.
- ADR-0011 amended with both decisions ("console and file are independent
sinks locally"; "bind process-level environment context once at startup").
Impact:
- configure_logging() signature changed to (logging_settings, app_settings);
both call sites (lifespan, qdrant_bootstrap CLI) updated.
This commit is contained in:
@@ -30,7 +30,7 @@ logger = structlog.get_logger(__name__)
|
||||
|
||||
async def bootstrap(settings: Settings | None = None) -> int:
|
||||
resolved = settings or Settings()
|
||||
configure_logging(resolved.logging)
|
||||
configure_logging(resolved.logging, resolved.app)
|
||||
client = create_client(resolved.qdrant)
|
||||
try:
|
||||
created = await ensure_chunks_collection(client, collection=resolved.qdrant.collection)
|
||||
|
||||
Reference in New Issue
Block a user