feat(rq): Support span streaming#6493
3 issues
Medium
`job.func_name` accessed without exception guard in streaming span attributes - `sentry_sdk/integrations/rq.py:93`
In the streaming path, job.func_name is accessed unguarded in the start_span attributes dict (line 93) after it was already guarded with capture_internal_exceptions() (line 82). If job.func_name raises an exception, the first access is silently swallowed but the second will propagate unhandled, crashing span creation for the job.
`job.func_name` accessed unguarded in span attributes after being protected by `capture_internal_exceptions` - `sentry_sdk/integrations/rq.py:92`
The SPANDATA.CODE_FUNCTION_NAME attribute accesses job.func_name a second time outside of capture_internal_exceptions, so if job.func_name raises (the same reason it's wrapped above), the exception propagates unhandled and the span is never started, leaving rv unassigned. Use the already-resolved span_name value instead.
Also found at:
sentry_sdk/integrations/rq.py:5
Low
Streaming test does not assert new `messaging.message.id` / `code.function.name` attributes - `tests/integrations/rq/test_rq.py:413-421`
The streaming branch of test_transaction_no_error only asserts sentry.op and span["name"]. The two new span attributes added by this PR in rq.py — SPANDATA.MESSAGING_MESSAGE_ID (set to job.id) and SPANDATA.CODE_FUNCTION_NAME (set to job.func_name) — are the stated purpose of the change but have no assertions. Consider adding checks so a regression that renames or drops either attribute would be caught.
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| security-review | 0 | 9.6s | $0.03 |
| code-review | 2 | 4m 9s | $0.78 |
| find-bugs | 1 | 10m 35s | $1.98 |
| skill-scanner | 0 | 6.9s | $0.02 |
⏱ 15m · 1.8M in / 86.7k out · $2.81