Skip to content

Mark task worker span as failed when the task fails#69146

Open
dstandish wants to merge 2 commits into
apache:mainfrom
astronomer:worker-span-error-on-failure
Open

Mark task worker span as failed when the task fails#69146
dstandish wants to merge 2 commits into
apache:mainfrom
astronomer:worker-span-error-on-failure

Conversation

@dstandish

Copy link
Copy Markdown
Contributor

run() converts every task failure into a returned state plus error rather than re-raising, so the worker.<task_id> OTel span never observed the failure through exception propagation and was left with an unset status. This derives the span status from run()'s result in main(), where the worker span is in scope regardless of trace detail level, so a failed task consistently shows as an error in traces.

Stacked on #67877 — the first commit in this diff belongs to that PR; review the top commit here (or review after #67877 merges and this is rebased).

closes: #69144


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

Comment thread task-sdk/tests/task_sdk/execution_time/test_task_runner.py Outdated
Comment thread task-sdk/src/airflow/sdk/execution_time/task_runner.py
dstandish added 2 commits July 2, 2026 09:09
run() converts every task failure into a returned state plus error rather than re-raising, so the worker.<task_id> OTel span never observed the failure through exception propagation and was left with an unset status. Derive the span status from run()'s result so a failed task shows as an error in traces, consistently and regardless of trace detail level.
If the SIGALRM-based kill ever fails to fire, the test would otherwise
block for the full sleep duration before failing with a not-raised
error; 200ms bounds that worst case while staying well above the 10ms
timeout.
@dstandish dstandish force-pushed the worker-span-error-on-failure branch from 21e7b21 to 0229bf6 Compare July 2, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task worker OTel span not marked ERROR on task failures

3 participants