Skip to content

Commit 3a93f9b

Browse files
authored
include task instance id in log printed by supervisor (apache#56383)
* include task instance id in log printed by supervisor * fix test
1 parent 322dcb3 commit 3a93f9b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

task-sdk/src/airflow/sdk/execution_time/supervisor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,13 @@ def supervise(
18961896

18971897
exit_code = process.wait()
18981898
end = time.monotonic()
1899-
log.info("Task finished", exit_code=exit_code, duration=end - start, final_state=process.final_state)
1899+
log.info(
1900+
"Task finished",
1901+
task_instance_id=str(ti.id),
1902+
exit_code=exit_code,
1903+
duration=end - start,
1904+
final_state=process.final_state,
1905+
)
19001906
if log_path and log_file_descriptor:
19011907
log_file_descriptor.close()
19021908
return exit_code

task-sdk/tests/task_sdk/execution_time/test_supervisor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ def test_supervise_handles_deferred_task(
667667
"level": "info",
668668
"logger": "supervisor",
669669
"loc": mocker.ANY,
670+
"task_instance_id": str(ti.id),
670671
} in captured_logs
671672

672673
def test_supervisor_handles_already_running_task(self):

0 commit comments

Comments
 (0)