Skip to content

feat(rq): Support span streaming#6493

Open
alexander-alderman-webb wants to merge 12 commits into
masterfrom
webb/rq/span-first
Open

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

Conversation

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor

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

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 thread sentry_sdk/integrations/rq.py Outdated
Comment thread tests/integrations/rq/test_rq.py Outdated
Comment thread tests/integrations/rq/test_rq.py
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Codecov Results 📊

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

📊 Comparison with Base Branch

Metric Change
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)
File Patch % Lines
sentry_sdk/integrations/rq.py 92.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 owner June 3, 2026 12:58
Comment thread sentry_sdk/integrations/rq.py Outdated
Comment thread tests/integrations/rq/test_rq.py
Comment thread sentry_sdk/integrations/rq.py Outdated
Comment thread tests/integrations/rq/test_rq.py
Comment thread sentry_sdk/integrations/rq.py
Comment thread sentry_sdk/integrations/rq.py
Comment thread tests/integrations/rq/test_rq.py
Comment thread sentry_sdk/integrations/rq.py Outdated
Comment thread sentry_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
Contributor Author

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.

Comment thread sentry_sdk/integrations/rq.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 thread sentry_sdk/integrations/rq.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate rq to span first

2 participants