Skip to content

Keep agent framework spans when worker tracing is off - #73903

Merged
kaxil merged 2 commits into
apache:mainfrom
astronomer:task-span-unsampled-parent
Sep 30, 2026
Merged

kaxil merged 2 commits into
apache:mainfrom
astronomer:task-span-unsampled-parent

Conversation

@kaxil

@kaxil kaxil commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

With no tracer provider installed in the worker, the task span still made the Dag run's propagated trace context current, and that context is marked as not sampled. A span the task's own code then started, under a tracer provider it installed itself, such as an agent framework's telemetry setup, inherited the unsampled flag and was dropped by the default parent-based sampler. So a Strands or ADK agent's own traces silently disappeared inside an Airflow task.

The task span now drops the parent context when it is unsampled and no tracer provider is installed, so a provider the task code installs later makes its own sampling decision.

The check is whether a provider is installed, not [traces] otel_on. With auto-instrumentation, a provider exists before the task starts even when Airflow's own tracing is off, and the Dag run was sampled out on purpose; keying on otel_on would override that decision. When a provider is installed, nothing changes.

Pairs with #73901, where Common AI's agent_framework_tracing() applies the same rule on Airflow versions without this fix.


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

With no tracer provider installed in the worker, the task span made the
Dag run's propagated trace context current even when that context was
unsampled. A span the task's own code then started under a tracer
provider it installed, such as an agent framework's, inherited the
unsampled flag and was dropped by the default parent-based sampler.

The check is whether a provider is installed, not the [traces] otel_on
setting, so a provider installed by auto-instrumentation keeps the Dag
run's sampling decision.

@Lee-W Lee-W left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few nits

@kaxil
kaxil merged commit e364ee7 into apache:main Sep 30, 2026
106 checks passed
@kaxil
kaxil deleted the task-span-unsampled-parent branch September 30, 2026 17:55
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.

2 participants