Skip to content

Commit 6470063

Browse files
authored
Arq integration ctx (#2600)
1 parent 248cb06 commit 6470063

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

sentry_sdk/integrations/arq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ async def _sentry_coroutine(ctx, *args, **kwargs):
169169
# type: (Dict[Any, Any], *Any, **Any) -> Any
170170
hub = Hub.current
171171
if hub.get_integration(ArqIntegration) is None:
172-
return await coroutine(*args, **kwargs)
172+
return await coroutine(ctx, *args, **kwargs)
173173

174174
hub.scope.add_event_processor(
175175
_make_event_processor({**ctx, "job_name": name}, *args, **kwargs)

tests/integrations/arq/test_arq.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22
import pytest
33

4-
from sentry_sdk import start_transaction
4+
from sentry_sdk import start_transaction, Hub
55
from sentry_sdk.integrations.arq import ArqIntegration
66

77
import arq.worker
@@ -234,3 +234,21 @@ async def dummy_job(_):
234234
assert len(event["spans"])
235235
assert event["spans"][0]["op"] == "queue.submit.arq"
236236
assert event["spans"][0]["description"] == "dummy_job"
237+
238+
239+
@pytest.mark.asyncio
240+
async def test_execute_job_without_integration(init_arq):
241+
async def dummy_job(_ctx):
242+
pass
243+
244+
dummy_job.__qualname__ = dummy_job.__name__
245+
246+
pool, worker = init_arq([dummy_job])
247+
# remove the integration to trigger the edge case
248+
Hub.current.client.integrations.pop("arq")
249+
250+
job = await pool.enqueue_job("dummy_job")
251+
252+
await worker.run_job(job.job_id, timestamp_ms())
253+
254+
assert await job.result() is None

0 commit comments

Comments
 (0)