dandanseo123 opened a new pull request, #64600:
URL: https://github.com/apache/airflow/pull/64600

   ### Description:
   In AF2, listener hooks (`on_task_instance_success/failed`) received the full 
ORM `TaskInstance` model, which includes `duration` and `queued_dttm`. In AF3, 
these hooks receive `RuntimeTaskInstance` — a minimal runtime object missing 
these fields. Plugins relying on them for metrics break when migrating to AF3.
   
   Additionally, DAG-level hooks (`on_dag_run_*`) already expose queue time via 
`DagRun.queued_at`, but task-level hooks do not expose the equivalent 
`queued_dttm`. This is inconsistent across the listener API.
   
   ### Changes
   
     **`duration`** : added as a computed property on `RuntimeTaskInstance`: 
`(end_date - start_date).total_seconds()`. This matches the ORM's 
`set_duration()` formula. Zero additional data flow, `start_date` and 
`end_date` already exist on `RuntimeTaskInstance`.
   
   - **`queued_dttm`**: Flows from DB → `TIRunContext` → `RuntimeTaskInstance` 
via the Execution API `ti_run` endpoint.
     - Both fields added to `RuntimeTaskInstanceProtocol`.
   
   ### Use case
   
     Listener plugins that publish task execution metrics need `duration` (how 
long the task ran) and `queued_dttm` (how long it waited in queue before 
starting). Without these fields, plugin authors must either query the DB 
directly from the listener hook or accept missing metrics, neither is ideal.
   
     ---
   
     - [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]

Reply via email to