10
10
from sentry_sdk .utils import (
11
11
capture_internal_exceptions ,
12
12
ensure_integration_enabled ,
13
- ensure_integration_enabled_async ,
14
13
event_from_exception ,
15
14
SENSITIVE_DATA_SUBSTITUTE ,
16
15
parse_version ,
@@ -71,9 +70,12 @@ def patch_enqueue_job():
71
70
# type: () -> None
72
71
old_enqueue_job = ArqRedis .enqueue_job
73
72
74
- @ensure_integration_enabled_async (ArqIntegration , old_enqueue_job )
75
73
async def _sentry_enqueue_job (self , function , * args , ** kwargs ):
76
74
# 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
+
77
79
with sentry_sdk .start_span (op = OP .QUEUE_SUBMIT_ARQ , description = function ):
78
80
return await old_enqueue_job (self , function , * args , ** kwargs )
79
81
@@ -84,9 +86,12 @@ def patch_run_job():
84
86
# type: () -> None
85
87
old_run_job = Worker .run_job
86
88
87
- @ensure_integration_enabled_async (ArqIntegration , old_run_job )
88
89
async def _sentry_run_job (self , job_id , score ):
89
90
# 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
+
90
95
with sentry_sdk .isolation_scope () as scope :
91
96
scope ._name = "arq"
92
97
scope .clear_breadcrumbs ()
@@ -157,9 +162,12 @@ def event_processor(event, hint):
157
162
def _wrap_coroutine (name , coroutine ):
158
163
# type: (str, WorkerCoroutine) -> WorkerCoroutine
159
164
160
- @ensure_integration_enabled_async (ArqIntegration , coroutine )
161
165
async def _sentry_coroutine (ctx , * args , ** kwargs ):
162
166
# 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
+
163
171
Scope .get_isolation_scope ().add_event_processor (
164
172
_make_event_processor ({** ctx , "job_name" : name }, * args , ** kwargs )
165
173
)
0 commit comments