-
-
Notifications
You must be signed in to change notification settings - Fork 6
Drive the task handler log level from the airflow.task logger #829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Churi12
wants to merge
1
commit into
stackabletech:main
Choose a base branch
from
Churi12:fix/task-handler-log-level-650
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+269
−13
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description in the changelog is confusing as it claims that dropping the level below INFO is possible for the log files/Vector without dropping the level of UI-displayed logs at the same time, but this line declares that they are coupled (whereas for anything above INFO they can diverge). Can you add a unit test that makes the actual behaviour clear and adjust the docs (changelog, logging.adoc and the example where it says "Write DEBUG to the log files") accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, and it was worse than the changelog wording: the example I added did not work.
I had file at DEBUG with airflow.task at INFO and claimed that wrote DEBUG to the log files and Vector while the UI stayed at INFO. It does not. The logger is clamped to min(INFO, requested), so with airflow.task at INFO the logger sits at INFO and the DEBUG records are discarded there, before the file handler ever sees them. I checked it by running the generated config through dictConfig rather than by reading it, which is how the claim survived this long.
So the behaviour is exactly as you describe. At or above INFO the handler and the logger diverge, and only the UI goes quiet while the console and file handlers keep receiving what it drops. Below INFO they are coupled, because a logger discards records before any of its handlers can filter them, so the logger has to open up too and the extra records then reach every destination. Lowering the UI on its own is not possible, and not because of how this is implemented: a handler cannot see what its logger already threw away.
Changes in the new push, no behaviour change:
One thing I should flag, separate from the above and not something this PR changes. At runtime Airflow calls set_context on the task logger when a task starts, and FileTaskHandler returns None there unless maintain_propagate is set, so logging_mixin.set_context sets propagate to False on airflow.task. After that point task records do not reach the root console and file handlers at all. That is Airflow behaviour and predates this PR, but it does mean the file and Vector levels have limited say over task logs regardless of what the logger threshold is. I kept the docs to claims I could verify and did not make the example depend on that path.
Also rebased onto main, the only conflict was the changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of gentle pointers - please let the reviewer mark the conversation as resolved, and, secondly, try and keep the AI-generated text in the comments to a minimum (preferably writing it yourself): the first half of the above is repeating what I had written. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood on both counts. I will leave the resolving to you and keep my replies shorter and in my own words.
On the change itself: the tests, the NOTE in logging.adoc and the changelog entry are updated, and the example now sets airflow.task to WARN instead of claiming DEBUG in the files with INFO in the UI, which does not work. Ready for another look whenever you have time.