Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions sentry_sdk/integrations/dedupe.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import weakref

import sentry_sdk
from sentry_sdk.utils import ContextVar, logger
from sentry_sdk.integrations import Integration
Expand Down Expand Up @@ -35,12 +37,24 @@ def processor(event, hint):
if exc_info is None:
return event

last_seen = integration._last_seen.get(None)
if last_seen is not None:
# last_seen is either a weakref or the original instance
last_seen = (
last_seen() if isinstance(last_seen, weakref.ref) else last_seen
)

exc = exc_info[1]
if integration._last_seen.get(None) is exc:
if last_seen is exc:
logger.info("DedupeIntegration dropped duplicated error event %s", exc)
return None

integration._last_seen.set(exc)
# we can only weakref non builtin types
try:
integration._last_seen.set(weakref.ref(exc))
except TypeError:
integration._last_seen.set(exc)

return event

@staticmethod
Expand Down