Skip to content

Commit a7529ed

Browse files
committed
Try simpler dedupe logic
1 parent a926640 commit a7529ed

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

sentry_sdk/integrations/dedupe.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import weakref
2+
13
import sentry_sdk
24
from sentry_sdk.utils import ContextVar, logger
35
from sentry_sdk.integrations import Integration
@@ -35,12 +37,22 @@ def processor(event, hint):
3537
if exc_info is None:
3638
return event
3739

40+
last_seen = integration._last_seen.get(None)
41+
if last_seen is not None:
42+
# last_seen is either a weakref or the original instance
43+
last_seen = last_seen() if callable(last_seen) else last_seen
44+
3845
exc = exc_info[1]
39-
if integration._last_seen.get(None) is exc:
46+
if last_seen is exc:
4047
logger.info("DedupeIntegration dropped duplicated error event %s", exc)
4148
return None
4249

43-
integration._last_seen.set(exc)
50+
# we can only weakref non builtin types
51+
try:
52+
integration._last_seen.set(weakref.ref(exc))
53+
except TypeError:
54+
integration._last_seen.set(exc)
55+
4456
return event
4557

4658
@staticmethod

0 commit comments

Comments
 (0)