Skip to content

Fix Dag run span parent context handling - #67424

Closed
henry3260 wants to merge 1 commit into
apache:mainfrom
henry3260:fix-dagrun-span-parent-context
Closed

henry3260 wants to merge 1 commit into
apache:mainfrom
henry3260:fix-dagrun-span-parent-context

Conversation

@henry3260

Copy link
Copy Markdown
Contributor

Why

Dag run spans are currently forced to root by always passing an empty context when the span is created.

That is useful for Dag runs created by Airflow entry points such as the API, scheduler, asset scheduling, UI trigger, and backfill, since those runs represent new workflow roots.

closes: #67210


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Codex GPT 5.5

  • 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.

@henry3260
henry3260 requested review from XD-DENG and ashb as code owners May 24, 2026 17:21
@potiuk potiuk added the ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. label May 26, 2026
@jason810496
jason810496 requested a review from dstandish May 28, 2026 06:12

@xBis7 xBis7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello, I just came across this PR and I've added some questions.

return leaf_tis

def _emit_dagrun_span(self, state: DagRunState):
def _should_force_root_dagrun_span(self) -> bool:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When is a dag run span supposed to not be root? Who should have triggered it?

What happens if we add a new span under the scheduler and the scheduler triggers a dag_run, whose span isn't root? The span is going to be a child of the scheduler's span. Is it something we want to do or not?

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.

I agree. I think the dag run should be the root span, not the web request which creates it.

A link between the dag run root span and the request span would make sense, but to me putting the dag run spans under this API just doesn't make sense.

@dstandish dstandish left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR it's a little different than what i was thinking when i made the associated issue.

The point was that when you create a dag run you have the capability to embed it in another trace from an external system. But that by default in general in airflow it would be a root span.

You are discriminating based on the run type, which does not seem like the right logic here. Thanks though.

@dstandish

Copy link
Copy Markdown
Contributor

Alternative that allows embedding into a parent trace via dag run conf: #69633

cc @ashb @xBis7 @jedcunningham

@henry3260

Copy link
Copy Markdown
Contributor Author

Closing in favor of #69633

@henry3260 henry3260 closed this Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow embedding a Dag run under an external trace via run conf

5 participants