Emit OpenTelemetry spans around task callback invocations#67659
Open
dstandish wants to merge 1 commit into
Open
Emit OpenTelemetry spans around task callback invocations#67659dstandish wants to merge 1 commit into
dstandish wants to merge 1 commit into
Conversation
Wrap each task callback and pre/post-execute hook invocation in a `callback.<kind>` span, gated on task span detail level > 1 — the follow-up to the `listener.<hook_name>` spans added in apache#67347. Covers the five state-change callbacks (on_execute/on_success/on_failure/on_retry/ on_skipped) and the pre_execute/post_execute hooks. The callback function name and index are recorded as span attributes, and a raising callback records ERROR status on its span.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #67347 (which added
listener.<hook_name>spans). This wraps each task callback and pre/post-execute hook invocation in acallback.<kind>span, gated on task span detail level > 1.Covered invocations (all routed through
create_executable_runner(...).run(...)intask-sdk/.../task_runner.py):on_execute_callback,on_success_callback,on_failure_callback,on_retry_callback,on_skipped_callback(centralized in_run_task_state_change_callbacks)pre_execute/post_executehooks in_execute_taskThe callback function name and index are recorded as span attributes; a raising state-change callback records
ERRORstatus on its span and is still swallowed/logged as before.Note: the span is added at the genuine call sites in
task_runner.py, not pushed down intocreate_executable_runner/callback_runner.py, because that runner is also reused to execute the actual task body (python_callable) in the standardPythonOperator— wrapping there would mislabel the main task execution.Tests: new
TestCallbackSpansunit tests intest_task_runner.py(span presence/attributes at level 2, none at level 1, error recording for a raising callback, pre/post-execute gating) and the otel integration test now assertscallback.on_execute_callback→_execute_taskandcallback.on_success_callback→finalize.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.7) following the guidelines