1010from sentry_sdk .utils import (
1111 capture_internal_exceptions ,
1212 ensure_integration_enabled ,
13- ensure_integration_enabled_async ,
1413 event_from_exception ,
1514 SENSITIVE_DATA_SUBSTITUTE ,
1615 parse_version ,
@@ -71,9 +70,12 @@ def patch_enqueue_job():
7170 # type: () -> None
7271 old_enqueue_job = ArqRedis .enqueue_job
7372
74- @ensure_integration_enabled_async (ArqIntegration , old_enqueue_job )
7573 async def _sentry_enqueue_job (self , function , * args , ** kwargs ):
7674 # type: (ArqRedis, str, *Any, **Any) -> Optional[Job]
75+ integration = sentry_sdk .get_client ().get_integration (ArqIntegration )
76+ if integration is None :
77+ return await old_enqueue_job (self , function , * args , ** kwargs )
78+
7779 with sentry_sdk .start_span (op = OP .QUEUE_SUBMIT_ARQ , description = function ):
7880 return await old_enqueue_job (self , function , * args , ** kwargs )
7981
@@ -84,9 +86,12 @@ def patch_run_job():
8486 # type: () -> None
8587 old_run_job = Worker .run_job
8688
87- @ensure_integration_enabled_async (ArqIntegration , old_run_job )
8889 async def _sentry_run_job (self , job_id , score ):
8990 # type: (Worker, str, int) -> None
91+ integration = sentry_sdk .get_client ().get_integration (ArqIntegration )
92+ if integration is None :
93+ return await old_run_job (self , job_id , score )
94+
9095 with sentry_sdk .isolation_scope () as scope :
9196 scope ._name = "arq"
9297 scope .clear_breadcrumbs ()
@@ -157,9 +162,12 @@ def event_processor(event, hint):
157162def _wrap_coroutine (name , coroutine ):
158163 # type: (str, WorkerCoroutine) -> WorkerCoroutine
159164
160- @ensure_integration_enabled_async (ArqIntegration , coroutine )
161165 async def _sentry_coroutine (ctx , * args , ** kwargs ):
162166 # type: (Dict[Any, Any], *Any, **Any) -> Any
167+ integration = sentry_sdk .get_client ().get_integration (ArqIntegration )
168+ if integration is None :
169+ return await coroutine (ctx , * args , ** kwargs )
170+
163171 Scope .get_isolation_scope ().add_event_processor (
164172 _make_event_processor ({** ctx , "job_name" : name }, * args , ** kwargs )
165173 )
0 commit comments