Skip to content

feat(rq): Support span streaming - #6493

Merged
alexander-alderman-webb merged 12 commits into
masterfrom
webb/rq/span-first
Jun 5, 2026
Merged

feat(rq): Support span streaming#6493
alexander-alderman-webb merged 12 commits into
masterfrom
webb/rq/span-first

Conversation

@alexander-alderman-webb

@alexander-alderman-webbalexander-alderman-webb commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description

In the streaming path, use

  • messaging.message.id instead of the rq-job.job_id extra
  • code.function.name instead of the rq-job.func extra

Extras not set as attributes

  • rq-job.args
  • rq-job.kwargs
  • rq-job.description
  • rq-job.enqueued_at
  • rq-job.started_at

Adapting Tests

sed commands used for converting transaction context managers:

  • sed -i '' 's/with start_transaction():/with sentry_sdk.traces.start_span(name="custom parent"):/g'

sed commands used for converting event capture:

  • sed -i '' 's/capture_events,/capture_items,/g'
  • sed -i '' 's/events = capture_events()/items = capture_items("event", "transaction", "span")/g'
  • sed -i '' 's/(error_event,) = events/(error_event,) = (item.payload for item in items if item.type == "event")/g'
  • sed -i '' 's/(event,) = events/spans = [item.payload for item in items if item.type == "span"]/g'
  • sed -i '' 's/event["spans"]/spans/g'

sed commands used for converting op:

  • sed -i '' 's/"op"/["attributes"]["sentry.op"]/g' tests/integrations/rq/test_rq.py

sed commands used for converting origin:

  • sed -i '' 's/["origin"]/["attributes"]["sentry.origin"]/g'

Issues

Closes#6053

Reminders

Comment threadsentry_sdk/integrations/rq.py Outdated
Comment threadtests/integrations/rq/test_rq.py Outdated
Comment threadtests/integrations/rq/test_rq.py
@github-actions

github-actionsBot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

88540 passed | ⏭️ 6025 skipped | Total: 94565 | Pass Rate: 93.63% | Execution Time: 298m 47s

📊 Comparison with Base Branch

MetricChange
Total Tests📈 +117
Passed Tests📈 +114
Failed Tests
Skipped Tests📈 +3

All tests are passing successfully.

✅ Patch coverage is 92.59%. Project has 2475 uncovered lines.
✅ Project coverage is 89.38%. Comparing base (base) to head (head).

Files with missing lines (1)
FilePatch %Lines
sentry_sdk/integrations/rq.py92.59%⚠️ 2 Missing and 3 partials
Coverage diff
@@ Coverage Diff @@## main #PR +/-##
==========================================
+ Coverage 89.38% 89.38% —%
==========================================
Files 192 192 —
Lines 23285 23302 +17
Branches 8002 8010 +8
==========================================
+ Hits 20811 20827 +16- Misses 2474 2475 +1- Partials 1309 1311 +2

Generated by Codecov Action

@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review June 3, 2026 12:58
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code ownerJune 3, 2026 12:58
Comment threadsentry_sdk/integrations/rq.py Outdated
Comment threadtests/integrations/rq/test_rq.py
Comment threadsentry_sdk/integrations/rq.py Outdated
Comment threadtests/integrations/rq/test_rq.py
Comment threadsentry_sdk/integrations/rq.py
Comment threadsentry_sdk/integrations/rq.py
Comment threadtests/integrations/rq/test_rq.py
Comment threadsentry_sdk/integrations/rq.py Outdated
Comment threadsentry_sdk/integrations/rq.py Outdated
(span,) = (
span
for span in spans
if span["attributes"].get("sentry.op") == "queue.task.rq"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to perform this filtering here? Or can we pull the last element off of spans via index access or .pop?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests failed in CI when I used a fixed index here.
The span list also includes spans from redis-py. Either the order is non-deterministic or there's differences across versions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting 🤔

Comment threadsentry_sdk/integrations/rq.py Outdated

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2e1a8c1. Configure here.

Comment threadsentry_sdk/integrations/rq.py
@alexander-alderman-webb
alexander-alderman-webb merged commit 3d126ff into masterJun 5, 2026
144 checks passed
@alexander-alderman-webb
alexander-alderman-webb deleted the webb/rq/span-first branch June 5, 2026 12:58
mgaligniana pushed a commit to mgaligniana/sentry-python that referenced this pull request Aug 9, 2026
Replace `job_id` and `func` from the `rq-job` extra with the `messaging.message.id` and `code.function.name` attributes in the streaming lifecycle mode. Do not set the remaining entries in the `rq-job` extra as attributes in the streaming mode.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate rq to span first

3 participants

@alexander-alderman-webb@ericapisani@sentrivana