Skip to content

Commit

Permalink
Arq integration ctx (#2600)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanovart authored Dec 15, 2023
1 parent 248cb06 commit 6470063
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/arq.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async def _sentry_coroutine(ctx, *args, **kwargs):
# type: (Dict[Any, Any], *Any, **Any) -> Any
hub = Hub.current
if hub.get_integration(ArqIntegration) is None:
return await coroutine(*args, **kwargs)
return await coroutine(ctx, *args, **kwargs)

hub.scope.add_event_processor(
_make_event_processor({**ctx, "job_name": name}, *args, **kwargs)
Expand Down
20 changes: 19 additions & 1 deletion tests/integrations/arq/test_arq.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import pytest

from sentry_sdk import start_transaction
from sentry_sdk import start_transaction, Hub
from sentry_sdk.integrations.arq import ArqIntegration

import arq.worker
Expand Down Expand Up @@ -234,3 +234,21 @@ async def dummy_job(_):
assert len(event["spans"])
assert event["spans"][0]["op"] == "queue.submit.arq"
assert event["spans"][0]["description"] == "dummy_job"


@pytest.mark.asyncio
async def test_execute_job_without_integration(init_arq):
async def dummy_job(_ctx):
pass

dummy_job.__qualname__ = dummy_job.__name__

pool, worker = init_arq([dummy_job])
# remove the integration to trigger the edge case
Hub.current.client.integrations.pop("arq")

job = await pool.enqueue_job("dummy_job")

await worker.run_job(job.job_id, timestamp_ms())

assert await job.result() is None

0 comments on commit 6470063

Please sign in to comment.