myps6415 commented on code in PR #67592:
URL: https://github.com/apache/airflow/pull/67592#discussion_r3314788763


##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -230,6 +234,17 @@ def ti_run(
                 extra=json.dumps({"host_name": ti_run_payload.hostname}) if 
ti_run_payload.hostname else None,
             )
         )
+        # Emit task.queued_duration on the first round of a try only — mirrors 
the skip
+        # logic from TaskInstance.emit_state_change_metric (an existing 
end_date means
+        # this is a deferral resume or similar, and the timing would be 
misleading).
+        # The registry-based legacy name 
dag.<dag_id>.<task_id>.queued_duration is
+        # emitted automatically by stats.timing via metrics_template.yaml.
+        if ti.queued_dttm is not None and ti.end_date is None:

Review Comment:
   Good catch, thanks! You're right that end_date stays None across a deferral, 
so I've added next_method is None to the guard and a deferral_resume test case. 
Done in 1da293d 



-- 
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]

Reply via email to