-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Simplify log context setting / propagation handling #28571
Conversation
7afdf03
to
48a9910
Compare
607225a
to
ec96172
Compare
…text After apache#28440, instead of having a task logger both at `airflow.task` and root logger, we only have it at root logger. This means we can remove the logic to set propagate to False, because there's no longer a risk of record processed by FTH twice. It also means we can remove the logic to walk up the logger hierarchy and set context because we don't need to hit both airflow.task and root -- there will only ever be one such handler instance. So in effect we deprecate the MAINTAIN_PROPAGATE logic and no longer set propagate=False by default. While we could probably remove the "DISABLE_PROPAGATE" logic too (it's only used by file processor) it doesn't really hurt to leave it. (cherry picked from commit b9ed441f9127503f55e338f728e68f10bc77f3df)
ec96172
to
7ece9f4
Compare
@@ -218,24 +224,14 @@ def set_context(logger, value): | |||
:param logger: logger | |||
:param value: value to set | |||
""" | |||
while logger: | |||
orig_propagate = logger.propagate | |||
if value is not None: |
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 changes in this function are mainly what this PR is about. We no longer need to "walk" the logger hierarchy because we no longer duplicate task logging handlers.
And as a result we no longer need to disable propagation by default, so we can revert back to the prior approach of just disabling when explicitly asked to do so.
class SetContextPropagate(enum.Enum): | ||
""":meta private:""" | ||
""" | ||
Deprecated. Previously used to allow disabling of propagation (the default) of |
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.
Since this is a private class, can we remove this outright?
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. |
Assumes #28440 merged first.
After #28440, instead of having a task logger both at
airflow.task
and root logger, we only have it at root logger. This means we can remove the logic to set propagate=False, because there's no longer a risk of record processed by FTH twice.It also means we can remove the logic to walk up the logger hierarchy and set context because we don't need to hit both airflow.task and root -- there will only ever be one such handler instance.
For file processor, we can go back to the old approach where we optionally disable propagation by returning a sentinel value, rather than disabling by default. Though we probably could remove it entirely.