1515from typing import TYPE_CHECKING
1616
1717if TYPE_CHECKING :
18- from typing import Any , Optional
18+ from typing import Any , Optional , List
1919
2020 from sentry_sdk ._types import Event , Hint
2121
2222
23- def _is_frame_in_app (tb_frame ):
24- # type: (Any) -> bool
25- client = sentry_sdk .get_client ()
26- if not client .is_active ():
27- return True
28-
29- in_app_include = client .options .get ("in_app_include" )
30- in_app_exclude = client .options .get ("in_app_exclude" )
31- project_root = client .options .get ("project_root" )
32-
23+ def _is_frame_in_app (tb_frame , in_app_include , in_app_exclude , project_root ):
24+ # type: (Any, Optional[List[str]], Optional[List[str]], Optional[str]) -> bool
3325 abs_path = tb_frame .tb_frame .f_code .co_filename
3426 namespace = tb_frame .tb_frame .f_globals .get ("__name__" )
3527
@@ -43,8 +35,10 @@ def _is_frame_in_app(tb_frame):
4335 )
4436
4537
46- def _create_exception_fingerprint (exc_info ):
47- # type: (Any) -> str
38+ def _create_exception_fingerprint (
39+ exc_info , in_app_include , in_app_exclude , project_root
40+ ):
41+ # type: (Any, Optional[List[str]], Optional[List[str]], Optional[str]) -> str
4842 """
4943 Creates a unique fingerprint for an exception based on type, message, and in-app traceback.
5044 """
@@ -61,7 +55,7 @@ def _create_exception_fingerprint(exc_info):
6155 frame_count = 0
6256
6357 for tb_frame in iter_stacks (tb ):
64- if not _is_frame_in_app (tb_frame ):
58+ if not _is_frame_in_app (tb_frame , in_app_include , in_app_exclude , project_root ):
6559 continue
6660
6761 file_path = tb_frame .tb_frame .f_code .co_filename or ""
@@ -87,13 +81,22 @@ class DedupeIntegration(Integration):
8781
8882 def __init__ (self ):
8983 # type: () -> None
90- # Store fingerprint of the last seen exception instead of the exception object
91- # This prevents memory leaks by not holding references to exception objects
9284 self ._last_fingerprint = ContextVar ("last-fingerprint" , default = None )
9385
86+ self .in_app_include = None # type: Optional[List[str]]
87+ self .in_app_exclude = None # type: Optional[List[str]]
88+ self .project_root = None # type: Optional[str]
89+
9490 @staticmethod
9591 def setup_once ():
9692 # type: () -> None
93+ client = sentry_sdk .get_client ()
94+ integration = client .get_integration (DedupeIntegration )
95+ if integration is not None :
96+ integration .in_app_include = client .options .get ("in_app_include" )
97+ integration .in_app_exclude = client .options .get ("in_app_exclude" )
98+ integration .project_root = client .options .get ("project_root" )
99+
97100 @add_global_event_processor
98101 def processor (event , hint ):
99102 # type: (Event, Optional[Hint]) -> Optional[Event]
@@ -109,7 +112,12 @@ def processor(event, hint):
109112 return event
110113
111114 # Create fingerprint from exception instead of storing the object
112- fingerprint = _create_exception_fingerprint (exc_info )
115+ fingerprint = _create_exception_fingerprint (
116+ exc_info ,
117+ integration .in_app_include ,
118+ integration .in_app_exclude ,
119+ integration .project_root ,
120+ )
113121 if not fingerprint :
114122 return event
115123
0 commit comments