wilmerdooley opened a new pull request, #67668: URL: https://github.com/apache/airflow/pull/67668
The `dag.<dag_id>.<task_id>.queued_duration` timer stopped being emitted after the Airflow 3 upgrade (#63503). In Airflow 2 it was sent from `TaskInstance.emit_state_change_metric` when the task moved to RUNNING. In Airflow 3 that transition happens in the execution API `ti_run` handler rather than in the ORM, so the emit no longer fired. Its sibling `scheduled_duration` still works because it is emitted server side from the scheduler on the QUEUED transition. This change emits `task.queued_duration` from `ti_run` on the QUEUED to RUNNING transition. The metric template already maps `task.queued_duration` to the legacy `dag.<dag_id>.<task_id>.queued_duration` name, so both the tagged and statsd forms are restored. It is guarded on `queued_dttm` being set and emitted only on the first try (no prior `end_date`), matching the Airflow 2 behavior. Unit tests cover the emit, the no-op when `queued_dttm` is missing, the first-try-only guard, and that a duplicate run request does not double-emit. closes: #63503 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: Claude Code 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]
