feat(logging): Separate ignore lists for events/breadcrumbs and sentry logs#5698
Merged
sl0thentr0py merged 1 commit intomasterfrom Mar 18, 2026
Merged
feat(logging): Separate ignore lists for events/breadcrumbs and sentry logs#5698sl0thentr0py merged 1 commit intomasterfrom
sl0thentr0py merged 1 commit intomasterfrom
Conversation
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
Other
🤖 This preview updates automatically when you update the PR. |
…y Logs Split _IGNORED_LOGGERS into two independent sets so that framework loggers silenced for events/breadcrumbs (e.g. django.server) can still be captured as Sentry Logs. - _IGNORED_LOGGERS controls EventHandler and BreadcrumbHandler - _IGNORED_LOGGERS_SENTRY_LOGS controls SentryLogsHandler - Add ignore_logger_for_sentry_logs() and unignore_logger*() helpers - Move _can_record into each handler class with its own ignore set - Split _handle_record into separate event and sentry-logs paths Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9a6ec82 to
d384b59
Compare
Contributor
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 20.72s All tests are passing successfully. ❌ Patch coverage is 25.00%. Project has 13681 uncovered lines. Files with missing lines (1)
Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Identical
_can_recordduplicated across two handler classes- Moved duplicate _can_record method to _BaseHandler, eliminating duplication while preserving SentryLogsHandler's override for different ignore list.
Or push these changes by commenting:
@cursor push 538bf4d0a5
Preview (538bf4d0a5)
diff --git a/sentry_sdk/integrations/logging.py b/sentry_sdk/integrations/logging.py
--- a/sentry_sdk/integrations/logging.py
+++ b/sentry_sdk/integrations/logging.py
@@ -226,6 +226,13 @@
)
)
+ def _can_record(self, record: "LogRecord") -> bool:
+ """Prevents ignored loggers from recording"""
+ for logger in _IGNORED_LOGGERS:
+ if fnmatch(record.name.strip(), logger):
+ return False
+ return True
+
def _logging_to_event_level(self, record: "LogRecord") -> str:
return LOGGING_TO_EVENT_LEVEL.get(
record.levelno, record.levelname.lower() if record.levelname else ""
@@ -247,13 +254,6 @@
Note that you do not have to use this class if the logging integration is enabled, which it is by default.
"""
- def _can_record(self, record: "LogRecord") -> bool:
- """Prevents ignored loggers from recording"""
- for logger in _IGNORED_LOGGERS:
- if fnmatch(record.name.strip(), logger):
- return False
- return True
-
def emit(self, record: "LogRecord") -> "Any":
with capture_internal_exceptions():
self.format(record)
@@ -346,13 +346,6 @@
Note that you do not have to use this class if the logging integration is enabled, which it is by default.
"""
- def _can_record(self, record: "LogRecord") -> bool:
- """Prevents ignored loggers from recording"""
- for logger in _IGNORED_LOGGERS:
- if fnmatch(record.name.strip(), logger):
- return False
- return True
-
def emit(self, record: "LogRecord") -> "Any":
with capture_internal_exceptions():
self.format(record)This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
alexander-alderman-webb
approved these changes
Mar 18, 2026
sl0thentr0py
added a commit
that referenced
this pull request
Mar 18, 2026
…y logs (#5698) Split `_IGNORED_LOGGERS` into two independent sets so that framework loggers silenced for events/breadcrumbs (e.g. `django.server`) can still be captured as Sentry Logs. - `_IGNORED_LOGGERS` controls `EventHandler` and `BreadcrumbHandler` - `_IGNORED_LOGGERS_SENTRY_LOGS` controls `SentryLogsHandler` - Add `ignore_logger_for_sentry_logs()` and `unignore_logger*()` helpers - Move `_can_record` into each handler class with its own ignore set - Split `_handle_record` into separate event and sentry-logs paths * resolves: #5689 * resolves: PY-2146 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sl0thentr0py
added a commit
that referenced
this pull request
Mar 18, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Description
Split
_IGNORED_LOGGERSinto two independent sets so that framework loggers silenced for events/breadcrumbs (e.g.django.server) can still be captured as Sentry Logs._IGNORED_LOGGERScontrolsEventHandlerandBreadcrumbHandler_IGNORED_LOGGERS_SENTRY_LOGScontrolsSentryLogsHandlerignore_logger_for_sentry_logs()andunignore_logger*()helpers_can_recordinto each handler class with its own ignore set_handle_recordinto separate event and sentry-logs pathsIssues