This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-1-test by this push:
new d3149fa89c0 [v3-1-test] Record missing `ti_failure` metrics for tasks
in Airflow 3 (#59731) (#59964)
d3149fa89c0 is described below
commit d3149fa89c034628482b6f20dfc15f8e68056814
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Dec 31 14:46:51 2025 +0100
[v3-1-test] Record missing `ti_failure` metrics for tasks in Airflow 3
(#59731) (#59964)
* emit ti failures stats
* fix whitespace, comment
(cherry picked from commit 98d59763242fac3fe79561967f226bfb3cfacfdf)
Co-authored-by: Sean Muth <[email protected]>
---
task-sdk/src/airflow/sdk/execution_time/task_runner.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/task-sdk/src/airflow/sdk/execution_time/task_runner.py
b/task-sdk/src/airflow/sdk/execution_time/task_runner.py
index 79df1beb605..611228ec201 100644
--- a/task-sdk/src/airflow/sdk/execution_time/task_runner.py
+++ b/task-sdk/src/airflow/sdk/execution_time/task_runner.py
@@ -1119,6 +1119,16 @@ def _handle_current_task_failed(
) -> tuple[RetryTask, TaskInstanceState] | tuple[TaskState, TaskInstanceState]:
end_date = datetime.now(tz=timezone.utc)
ti.end_date = end_date
+
+ # Record operator and task instance failed metrics
+ operator = ti.task.__class__.__name__
+ stats_tags = {"dag_id": ti.dag_id, "task_id": ti.task_id}
+
+ Stats.incr(f"operator_failures_{operator}", tags=stats_tags)
+ # Same metric with tagging
+ Stats.incr("operator_failures", tags={**stats_tags, "operator": operator})
+ Stats.incr("ti_failures", tags=stats_tags)
+
if ti._ti_context_from_server and ti._ti_context_from_server.should_retry:
return RetryTask(end_date=end_date), TaskInstanceState.UP_FOR_RETRY
return (