Move Post Execution Log Grouping behind Exception Print #40146
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In PR #38021 we added log grouping into log printing. We all love this feature but I got some negative feedback for cases where people look for a failed task: If you are not an Airflow expert and you look for the exception/eror in the logs, in many cases the exception is not printed. If the task execution fails in an exception the exception trace will be in the "Post task execution logs" group that you need to un-fold.
This PR moves the "Post task execution logs" behind the exception print. Side effect is (due to placement) that error handling code might be called before (on success/skip handler will be called after/inside the group though).
Before - no exception in failed task:
![image](https://private-user-images.githubusercontent.com/95105677/337930798-038860cc-4154-41aa-8df5-6d609bf537b8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4MzUzMzgsIm5iZiI6MTczOTgzNTAzOCwicGF0aCI6Ii85NTEwNTY3Ny8zMzc5MzA3OTgtMDM4ODYwY2MtNDE1NC00MWFhLThkZjUtNmQ2MDliZjUzN2I4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE3VDIzMzAzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYxN2UxN2E1YTk2MGZkZDM1NjhkZGQ1OTZhMDU3YjkxODVjMWY1NzE2ODBhZWQwNmVmZWM4ZTA2NjcxZmEzNzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.TYHbYh_FsOJEoyE5VGEBALbVOqUJxIZT2yKtSwQ675M)
...and you needed to un-fold to see it - note that on_failure_callback is also executed before post block:
![image](https://private-user-images.githubusercontent.com/95105677/337930821-9dbe0b69-b281-466b-b369-7da300c9ef41.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4MzUzMzgsIm5iZiI6MTczOTgzNTAzOCwicGF0aCI6Ii85NTEwNTY3Ny8zMzc5MzA4MjEtOWRiZTBiNjktYjI4MS00NjZiLWIzNjktN2RhMzAwYzllZjQxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE3VDIzMzAzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIzYTE1NGM2YjBiZTM1ZWI1NzU1N2YwNDEzZTM1NDgxZjQyNDgzNTZjYjQ0OTRhMzNlOGMyNDhlMGE2ZGI0ZDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.5XMhWOQjiWqVg2LRe-c7EV6Q7c0oeYb0LOIFcuqFzEY)
After - exception is moved in front of log group:
![image](https://private-user-images.githubusercontent.com/95105677/337930864-d0a76dd6-eadf-48ef-8181-2b9c2860685d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4MzUzMzgsIm5iZiI6MTczOTgzNTAzOCwicGF0aCI6Ii85NTEwNTY3Ny8zMzc5MzA4NjQtZDBhNzZkZDYtZWFkZi00OGVmLTgxODEtMmI5YzI4NjA2ODVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE3VDIzMzAzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAyNmQ3MWM3YmViZWZmODRmNWYwODMwMDAxMTAzMDQ0YmNlNzViZDIxZTM5ZjljOThmN2Q0YzRiMmEwN2M5MTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.jtT-cYfjed3JTHHvSJ57diBGi8vLDgvNcQs9LjmvOCw)
Plus tasks without exception have no change in beautiful text:
![image](https://private-user-images.githubusercontent.com/95105677/337931050-e7adeaaa-f455-4443-ad30-7327da1b5025.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4MzUzMzgsIm5iZiI6MTczOTgzNTAzOCwicGF0aCI6Ii85NTEwNTY3Ny8zMzc5MzEwNTAtZTdhZGVhYWEtZjQ1NS00NDQzLWFkMzAtNzMyN2RhMWI1MDI1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE3VDIzMzAzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFiZmRlNWUyNjdiMWFiMzQzMTI4NWNhNWI4NmFkZWViNmRhNmRjZWZhNDdiMjZiMDJhNTc4YmI2OTQxMjVjZTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.W1SxLu8PBPOamZ-j7-tGbZ9qNID2_qvvEQFPCtFZPh4)