Skip to content

[v3-2-test] Fix OTel metrics lost in forked task processes (#64703)#64720

Merged
potiuk merged 1 commit intov3-2-testfrom
backport-ff77bd2-v3-2-test
Apr 6, 2026
Merged

[v3-2-test] Fix OTel metrics lost in forked task processes (#64703)#64720
potiuk merged 1 commit intov3-2-testfrom
backport-ff77bd2-v3-2-test

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Apr 4, 2026

Reset the OTel SDK's Once() guard on _METER_PROVIDER_SET_ONCE before
calling set_meter_provider() in get_otel_logger(). When a forked child
process re-initializes Stats (detected via PID mismatch in stats.py),
the inherited Once._done = True flag prevents the new MeterProvider from
being registered. The child falls back to the parent's stale provider
whose PeriodicExportingMetricReader thread is dead after fork, causing
task-level metrics like ti.finish to be silently dropped.

The fix resets _done and _METER_PROVIDER before each set_meter_provider()
call. On first initialization (no fork), _done is already False so this
is a no-op. On re-initialization after fork, it allows the new provider
to be set correctly.
(cherry picked from commit ff77bd2)

Co-authored-by: Michael Black 4128408+MichaelRBlack@users.noreply.github.com
Closes: #64690

Reset the OTel SDK's Once() guard on _METER_PROVIDER_SET_ONCE before
calling set_meter_provider() in get_otel_logger(). When a forked child
process re-initializes Stats (detected via PID mismatch in stats.py),
the inherited Once._done = True flag prevents the new MeterProvider from
being registered. The child falls back to the parent's stale provider
whose PeriodicExportingMetricReader thread is dead after fork, causing
task-level metrics like ti.finish to be silently dropped.

The fix resets _done and _METER_PROVIDER before each set_meter_provider()
call. On first initialization (no fork), _done is already False so this
is a no-op. On re-initialization after fork, it allows the new provider
to be set correctly.
(cherry picked from commit ff77bd2)

Co-authored-by: Michael Black <4128408+MichaelRBlack@users.noreply.github.com>
Closes: #64690
@potiuk potiuk marked this pull request as ready for review April 6, 2026 13:07
@potiuk potiuk merged commit dd7e2a6 into v3-2-test Apr 6, 2026
4 checks passed
@potiuk potiuk deleted the backport-ff77bd2-v3-2-test branch April 6, 2026 13:07
vatsrahul1001 pushed a commit that referenced this pull request Apr 8, 2026
…64720)

Reset the OTel SDK's Once() guard on _METER_PROVIDER_SET_ONCE before
calling set_meter_provider() in get_otel_logger(). When a forked child
process re-initializes Stats (detected via PID mismatch in stats.py),
the inherited Once._done = True flag prevents the new MeterProvider from
being registered. The child falls back to the parent's stale provider
whose PeriodicExportingMetricReader thread is dead after fork, causing
task-level metrics like ti.finish to be silently dropped.

The fix resets _done and _METER_PROVIDER before each set_meter_provider()
call. On first initialization (no fork), _done is already False so this
is a no-op. On re-initialization after fork, it allows the new provider
to be set correctly.
(cherry picked from commit ff77bd2)


Closes: #64690

Co-authored-by: Michael Black <4128408+MichaelRBlack@users.noreply.github.com>
vatsrahul1001 pushed a commit that referenced this pull request Apr 15, 2026
…64720)

Reset the OTel SDK's Once() guard on _METER_PROVIDER_SET_ONCE before
calling set_meter_provider() in get_otel_logger(). When a forked child
process re-initializes Stats (detected via PID mismatch in stats.py),
the inherited Once._done = True flag prevents the new MeterProvider from
being registered. The child falls back to the parent's stale provider
whose PeriodicExportingMetricReader thread is dead after fork, causing
task-level metrics like ti.finish to be silently dropped.

The fix resets _done and _METER_PROVIDER before each set_meter_provider()
call. On first initialization (no fork), _done is already False so this
is a no-op. On re-initialization after fork, it allows the new provider
to be set correctly.
(cherry picked from commit ff77bd2)


Closes: #64690

Co-authored-by: Michael Black <4128408+MichaelRBlack@users.noreply.github.com>
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Apr 15, 2026
@vatsrahul1001 vatsrahul1001 added this to the Airflow 3.2.1 milestone Apr 15, 2026
vatsrahul1001 pushed a commit that referenced this pull request Apr 15, 2026
…64720)

Reset the OTel SDK's Once() guard on _METER_PROVIDER_SET_ONCE before
calling set_meter_provider() in get_otel_logger(). When a forked child
process re-initializes Stats (detected via PID mismatch in stats.py),
the inherited Once._done = True flag prevents the new MeterProvider from
being registered. The child falls back to the parent's stale provider
whose PeriodicExportingMetricReader thread is dead after fork, causing
task-level metrics like ti.finish to be silently dropped.

The fix resets _done and _METER_PROVIDER before each set_meter_provider()
call. On first initialization (no fork), _done is already False so this
is a no-op. On re-initialization after fork, it allows the new provider
to be set correctly.
(cherry picked from commit ff77bd2)


Closes: #64690

Co-authored-by: Michael Black <4128408+MichaelRBlack@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants