Vamsi-klu opened a new pull request, #67765:
URL: https://github.com/apache/airflow/pull/67765
### What / impact
When a Dag run timed out, the scheduler emitted the `dagrun.duration.failed`
timing metric with only a `dag_id` tag. Every other `dagrun.duration.*`
emission also carries `run_type`, so dashboards and alerts that segment by
`run_type` silently dropped timed-out runs (or saw an inconsistent tag set).
After this change the timeout path emits both `dag_id` and `run_type`,
consistent with normal completion.
### Why
The timeout branch in `_schedule_dag_run` hardcoded `tags={"dag_id":
dag_run.dag_id}`, while the canonical emitter
`DagRun._emit_duration_stats_for_finished_state` uses `dag_run.stats_tags`
(which includes `run_type`). This replaces the hardcoded dict with
`dag_run.stats_tags`. `run_type` is `NOT NULL` and low-cardinality, so the new
tag set is a safe strict superset of the old one and the metric name is
unchanged.
### How it unblocks
Makes timeout-duration metrics consistent and usable in `run_type`-segmented
observability. Supersedes #64768, which stalled on CI/static checks rather than
design — this keeps the diff to a single value change and ships green static
checks, including the metrics-registry sync check that blocked the prior
attempt.
### Tests
One new regression test in `test_scheduler_job.py`, verified to fail on the
unfixed code, asserting the `dagrun.duration.failed` timing call carries
`tags={"dag_id": …, "run_type": …}`. Full scheduler suite passes; mypy +
pre-commit + manual static checks (incl. metrics-registry sync) are green.
closes: #64765
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 4.8)
Generated-by: Claude Code (Opus 4.8) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]