Skip to content

Commit 0f01912

Browse files
committed
Fixed tests
1 parent 632dc68 commit 0f01912

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

sentry_sdk/integrations/arq.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from sentry_sdk.integrations import DidNotEnable, Integration
66
from sentry_sdk.integrations.logging import ignore_logger
77
from sentry_sdk.scope import should_send_default_pii
8-
from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_TASK
8+
from sentry_sdk.tracing import TRANSACTION_SOURCE_TASK
99
from sentry_sdk.utils import (
1010
capture_internal_exceptions,
1111
ensure_integration_enabled,
@@ -37,6 +37,8 @@
3737

3838
ARQ_CONTROL_FLOW_EXCEPTIONS = (JobExecutionFailed, Retry, RetryJob)
3939

40+
DEFAULT_TRANSACTION_NAME = "unknown arq task"
41+
4042

4143
class ArqIntegration(Integration):
4244
identifier = "arq"
@@ -101,18 +103,20 @@ async def _sentry_run_job(self, job_id, score):
101103

102104
with sentry_sdk.isolation_scope() as scope:
103105
scope._name = "arq"
106+
scope.set_transaction_name(
107+
DEFAULT_TRANSACTION_NAME, source=TRANSACTION_SOURCE_TASK,
108+
)
104109
scope.clear_breadcrumbs()
105110

106-
transaction = Transaction(
107-
name="unknown arq task",
108-
status="ok",
111+
with sentry_sdk.start_span(
109112
op=OP.QUEUE_TASK_ARQ,
113+
name=DEFAULT_TRANSACTION_NAME,
110114
source=TRANSACTION_SOURCE_TASK,
111115
origin=ArqIntegration.origin,
112-
)
113-
114-
with sentry_sdk.start_transaction(transaction):
115-
return await old_run_job(self, job_id, score)
116+
) as span:
117+
return_value = await old_run_job(self, job_id, score)
118+
span.set_status(SPANSTATUS.OK)
119+
return return_value
116120

117121
Worker.run_job = _sentry_run_job
118122

0 commit comments

Comments
 (0)