-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Introduce a helper to reduce logs in frequently invoked codepaths. #34977
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #34977 +/- ##
=========================================
Coverage 54.50% 54.51%
Complexity 1479 1479
=========================================
Files 1012 1013 +1
Lines 160667 160691 +24
Branches 1079 1079
=========================================
+ Hits 87577 87603 +26
+ Misses 70990 70988 -2
Partials 2100 2100
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
+1 this is a useful helper. Always wondering there is a Python implementation of absl's LOG_EVERY_N_SEC |
Assigning reviewers: R: @claudevdm for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
f6384e1
to
995e489
Compare
Looks like there is: Looks interesting, i wonder if we can use absl.logging instead without causing some unintentional consequences. It already has all these helpers. |
Took a look. I think the main issue is we adopted hierarchical logging with named loggers to allow for per-file logging levels. Absl uses a different method of per-file logging that would require code and documentation changes to adopt, so seems like not a drop-in replacement. absl-py apis look better, I'll try to TAL if we can have something similar. |
Found an implementation accomplishes what i'd like to have, will need to polish the change a bit. |
We have several places in Python SDK where a certain log entry is emitted multiple times, when a single warning would be sufficient. This is causing excessive noise, particularly visible during job submission, when INFO logs are enabled.
We also have codepaths where we may want to log a particular message, but not more often than once per x minutes. Every time that happens, we add the same logic counting time, for example:
beam/sdks/python/apache_beam/runners/worker/data_plane.py
Line 167 in bea0444
I suggest to introduce a helper that can streamline this functionality at the cost storing identifiers of a log entry in memory, such as a position in the codebase where the log is emitted, or some identifier to dedup or group similar messages.
For example, a caller can use an ID to print a GCS bucket configuration note only once per bucket, using bucket name as an ID.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.