|
5 | 5 | from sentry_sdk.integrations import DidNotEnable, Integration |
6 | 6 | from sentry_sdk.integrations.logging import ignore_logger |
7 | 7 | 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 |
9 | 9 | from sentry_sdk.utils import ( |
10 | 10 | capture_internal_exceptions, |
11 | 11 | ensure_integration_enabled, |
|
37 | 37 |
|
38 | 38 | ARQ_CONTROL_FLOW_EXCEPTIONS = (JobExecutionFailed, Retry, RetryJob) |
39 | 39 |
|
| 40 | +DEFAULT_TRANSACTION_NAME = "unknown arq task" |
| 41 | + |
40 | 42 |
|
41 | 43 | class ArqIntegration(Integration): |
42 | 44 | identifier = "arq" |
@@ -101,18 +103,20 @@ async def _sentry_run_job(self, job_id, score): |
101 | 103 |
|
102 | 104 | with sentry_sdk.isolation_scope() as scope: |
103 | 105 | scope._name = "arq" |
| 106 | + scope.set_transaction_name( |
| 107 | + DEFAULT_TRANSACTION_NAME, source=TRANSACTION_SOURCE_TASK, |
| 108 | + ) |
104 | 109 | scope.clear_breadcrumbs() |
105 | 110 |
|
106 | | - transaction = Transaction( |
107 | | - name="unknown arq task", |
108 | | - status="ok", |
| 111 | + with sentry_sdk.start_span( |
109 | 112 | op=OP.QUEUE_TASK_ARQ, |
| 113 | + name=DEFAULT_TRANSACTION_NAME, |
110 | 114 | source=TRANSACTION_SOURCE_TASK, |
111 | 115 | 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 |
116 | 120 |
|
117 | 121 | Worker.run_job = _sentry_run_job |
118 | 122 |
|
|
0 commit comments