ashb opened a new pull request, #63365:
URL: https://github.com/apache/airflow/pull/63365
Previously gunicorn/uvicorn each installed their own log handlers and
formatters, bypassing Airflow's structlog ProcessorFormatter entirely. This
meant:
- Gunicorn set up its own StreamHandler on gunicorn.error / gunicorn.access,
so those records never went through structlog.
- Uvicorn workers called logging.config.dictConfig(LOGGING_CONFIG) on
startup,
overwriting the structlog configuration that was applied before gunicorn
started.
- HTTP access log lines came from uvicorn's built-in access logger
(unstructured).
- Python warnings.warn() calls and unhandled exceptions bypassed structlog
too.
Now:
- AirflowGunicornLogger overrides setup() to skip installing gunicorn's own
handlers and lets records propagate to root (where structlog is
configured).
- AirflowUvicornWorker sets log_config=None so uvicorn doesn't clobber the
logging config, and access_log=False since we handle that ourselves.
- HttpAccessLogMiddleware replaces uvicorn's access log: one structured event
per request with method, path, status code, duration (µs), client address,
and the x-request-id header bound to the structlog context for the request
lifetime. Health-check paths are excluded to avoid noise.
- configure_logging() now explicitly silences uvicorn.access /
gunicorn.access
and routes uvicorn.error / gunicorn.error through the default handler.
- Python warnings are intercepted and emitted as structured py.warnings log
events instead of going to stderr.
- In JSON log mode, unhandled exceptions are emitted via structlog rather
than
the plain-text default sys.excepthook.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]