Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arq integration ctx #2600

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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