Emit OpenTelemetry spans around listener hook calls#67347
Draft
dstandish wants to merge 1 commit into
Draft
Conversation
Push span creation down into ListenerManager via pluggy's add_hookcall_monitoring so every hook call gets a `listener.<hook_name>` span automatically, gated on task span detail level > 1. Callers no longer need to wrap individual hook invocations. Also makes the existing _after_hookcall safe against listener exceptions: previously `outcome.get_result()` was called unconditionally and would re-raise, skipping the rest of the callback.
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.
Pushes span creation down into
ListenerManagerso every pluggy hook call automatically gets alistener.<hook_name>span (gated on task span detail level > 1). Callers no longer need to wrap individuallm.hook.foo(...)invocations.Done via pluggy's
add_hookcall_monitoringbefore/after pair, paired with a per-thread span stack so concurrent and nested calls stay isolated.Also fixes a latent bug in the existing
_after_hookcall: it calledoutcome.get_result()unconditionally, which re-raises on listener exceptions and would have skipped span teardown. It now checksoutcome.excinfofirst and records the exception on the span before exiting the context.The detail-level threshold constants are inlined (with a comment) rather than imported from
airflow_shared.observability.traces, to avoid adding a cross-shared-library dependency that destabilised the deps-propagation prek hook.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.7) following the guidelines