dsuhinin commented on code in PR #68393:
URL: https://github.com/apache/airflow/pull/68393#discussion_r3658940692
##########
airflow-core/src/airflow/settings.py:
##########
@@ -816,6 +835,7 @@ def initialize():
import_local_settings()
configure_logging()
configure_otel(conf)
+ _initialize_stats()
Review Comment:
The per-fork reset is there — it just doesn't live at the call sites.
stats.py registers
os.register_at_fork(after_in_child=_reset_backend_after_fork) at module level
(since #63932), which sets _backend = None in every forked child. So under
preload a worker doesn't keep the master's provider: the first metric emitted
in the worker goes through _get_backend() → _factory() → get_otel_logger().
That lazy rebuild is exactly what re-runs the factory in the child — and it's
what makes the Once() guard reset reachable, not unreachable: without it the
rebuilt provider couldn't replace the inherited one. The call sites this PR
removes were redundant with that hook.
I
verified it end to end: gunicorn api-server with preload_app and 2 workers,
plus a test plugin touching Stats at import time so the backend and its
exporter thread are built in the master before the fork (the worst case here).
The master exports its metric, and both workers export request-time metrics
tagged
with their own PIDs afterwards. I also added a unit test for the hook
itself — TestBackendResetAfterFork in the shared observability tests does a
real os.fork() and asserts the child's backend is reset and rebuilt fresh.
--
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]