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

   `previously_succeeded` ("Number of previously succeeded task instances") is 
listed in the metrics registry and docs, but its only emit site is 
`TaskInstance._check_and_change_state_before_execution`, which nothing calls in 
Airflow 3. Workers move a task to running through the `ti_run` Execution API 
route instead, and when they are handed a task instance that already succeeded, 
`ti_run` answers 409 `invalid_state` with `previous_state: success` without 
counting anything.
   
   This emits the counter from that 409 branch when the previous state is 
`success`, following the approach #67592 used to restore `task.queued_duration` 
in the same route. Tags match `TaskInstance.stats_tags` (Dag run tags, 
including team and Dag tags when enabled, plus `task_id`). The Task SDK client 
only retries 5xx and connection errors, so each refused start is counted once.
   
   Tests: added `test_ti_run_previously_succeeded_metric`, covering `success` 
(counted) and `failed` / `skipped` / `up_for_retry` (409 but not counted). The 
`success` case fails without the fix.
   
   closes: #75366
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Opus 5.5) 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