Improve logging readability with DockerOperator
Related: discussion
When DockerOperator logs are displayed in the Airflow UI, the logs from the container are prefixed with "[asctime UTC] {docker.py:[line]} INFO -" in some "random" lines. This prefix can disrupt the logging format inside the container and is often redundant:
- [asctime UTC]: This timestamp may duplicate timestamps already present in the container logs
- {docker.py:[line]}: This information is constant when the container is running and provides little value
- INFO: The logging level is often misleading, as the actual log content may be of a different severity
This PR removes these three components from the logging prefix and only displaying the logs from the container, which aims to enhance the readability of the entire logging output.
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst) Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
- In case of a new feature add useful documentation (in docstrings or in
docs/directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it. - Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the Airflow Coding style.
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits. Apache Airflow is a community-driven project and together we are making it better 🚀. In case of doubts contact the developers at: Mailing List: [email protected] Slack: https://s.apache.org/airflow-slack
Hi @potiuk, I've added a PR to address your previous discussion with MattiaGallegati.
Would like to have your review on this. Thanks.
I find it as a useful optional feature, but it absolutely cannot be enabled by default. It should be quite a bit more generic also in order to be useful - you should be able to not only enable it, but also provide an optional formatting + documentation and examples of usage in HowTo as well. It also needs unit tests testing it.
I find it as a useful optional feature, but it absolutely cannot be enabled by default. It should be quite a bit more generic also in order to be useful - you should be able to not only enable it, but also provide an optional formatting + documentation and examples of usage in HowTo as well. It also needs unit tests testing it.
Good insights. I pushed a new commit based on these points. @potiuk
Can you add the test cases for this change?
Change has been made in the new PR. Further review will be very welcomed and appreciated. @dirrao
conflicts to resolve when rebasing.
conflicts to resolve when rebasing.
Resolved.
Still try/finally not solved
Still try/finally not solved
Can you be more specific please @potiuk? Because we indeed added _restore_log_formatter into the except clause, which will revert the changes if formatters are not fully updated to the customized one.
If you are referring to the original suggestion:
Maybe I am nissing something I thought about try/finally where _restore_log_formatter will be called in the finally clause.
I think we've confused something here, because _restore_log_formatter will roll back all formatters no matter the try block succeeded or not, and makes this feature not working anymore.
change()
try:
do stuff
finally:
restore()
change() try: do stuff finally: restore()
Ha! I misunderstood which try-catch block you were mentioning before. Updated, this is indeed a good catch, thanks.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.