Skip to content

Allow forcing trace head-sampling per DAG run via conf#68860

Draft
dstandish wants to merge 2 commits into
apache:mainfrom
astronomer:trace-sampled-conf-override
Draft

Allow forcing trace head-sampling per DAG run via conf#68860
dstandish wants to merge 2 commits into
apache:mainfrom
astronomer:trace-sampled-conf-override

Conversation

@dstandish

Copy link
Copy Markdown
Contributor

Adds a reserved run conf key, airflow/trace_sampled, that overrides the head-sampling decision for an individual DAG run:

  • true — always trace this run
  • false — never trace it
  • absent — leave the decision to the configured sampler (OTEL_TRACES_SAMPLER)

This lets a deployment running a head sampler guarantee a specific run is traced (e.g. debugging a flaky DAG) or excluded (a noisy run) regardless of the configured sampling ratio. Only an explicit boolean is honored — strings, numbers, and other values are ignored and fall through to the sampler, so a malformed conf value can neither silently change sampling nor fail run creation.

Depends on #68592 (Forward run-identity attributes to the trace sampler), on which this is stacked — it touches the same new_dagrun_trace_carrier signature and carrier call sites. Targeting main; once #68592 merges, this PR's diff reduces to the override change alone. It can merge after #68592.


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

Builds on the head-sampling foundation (apache#68591) by forwarding run-identity
attributes (dag_id, run_type) to the trace sampler, so a custom sampler can
differentiate the head-sampling decision by run kind.
Deployments running a head sampler sometimes need to guarantee a specific run
is traced (debugging a flaky DAG) or excluded (a noisy run), regardless of the
configured sampling ratio. A reserved run conf key, airflow/trace_sampled,
provides that per-run override: true always traces the run, false never does,
and absent leaves the decision to the sampler. Only an explicit bool is honored
so a malformed value can neither silently change sampling nor fail run creation.
@dstandish dstandish marked this pull request as draft June 22, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant