Skip to content
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

Closed

Conversation

dstandish
Copy link
Contributor

@dstandish dstandish commented Dec 24, 2022

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.

@dstandish dstandish changed the title WIP - Don't disable propagation or walk logger tree with set_context WIP - Simplify log context setting / propagation handling Dec 30, 2022
@dstandish dstandish force-pushed the try-no-propagate-shenanigans branch 2 times, most recently from 607225a to ec96172 Compare January 10, 2023 07:02
@dstandish dstandish changed the title WIP - Simplify log context setting / propagation handling Simplify log context setting / propagation handling Jan 10, 2023
@dstandish dstandish marked this pull request as ready for review January 10, 2023 08:16
…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)
@@ -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:
Copy link
Contributor Author

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.

@dstandish dstandish added this to the Airflow 2.6.0 milestone Jan 28, 2023
class SetContextPropagate(enum.Enum):
""":meta private:"""
"""
Deprecated. Previously used to allow disabling of propagation (the default) of
Copy link
Member

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?

@github-actions
Copy link

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.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Mar 17, 2023
@github-actions github-actions bot closed this Mar 23, 2023
@ephraimbuddy ephraimbuddy removed this from the Airflow 2.6.0 milestone Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI area:logging stale Stale PRs per the .github/workflows/stale.yml policy file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants