Skip to content

feat(grpc): Support span streaming#6204

Merged
alexander-alderman-webb merged 16 commits intomasterfrom
webb/grpc/span-first
May 8, 2026
Merged

feat(grpc): Support span streaming#6204
alexander-alderman-webb merged 16 commits intomasterfrom
webb/grpc/span-first

Conversation

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor

@alexander-alderman-webb alexander-alderman-webb commented May 5, 2026

Description

In the streaming path, use

  • rpc.method instead of method
  • rpc.response.status_code instead of code

Dropped attributes:

  • type

Adapting Tests

sed commands used for converting transaction context managers:

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

sed commands used for converting specific attributes:

  • sed -i '' '/"type": /d'
  • sed -i '' 's/code/rpc.response.status_code/g'
  • sed -i '' 's/method/rpc.method/g'

sed commands used for converting event capture:

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

sed commands used for converting op:

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

sed commands used for converting origin:

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

sed commands used for converting description:

  • sed -i '' 's/description/name/g'

sed commands used for converting data to attributes:

  • sed -i '' 's/data/attributes/g'

sed commands for converting trace id:

  • sed -i '' 's/["contexts"]["trace"]["trace_id"]/["trace_id"]/g'

other test changes:

  • sed -i '' 's/, channel = grpc_server_and_channel/, channel = await grpc_server_and_channel(span_streaming)/g'
  • sed -i '' 's/events.read_event()/items = items.read_event()/g'
  • sed -i '' 's/events.write_file.close()/items.write_file.close()/g'

Issues

Closes #6027

Reminders

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Codecov Results 📊

146 passed | Total: 146 | Pass Rate: 100% | Execution Time: 21.58s

All tests are passing successfully.

❌ Patch coverage is 2.04%. Project has 14293 uncovered lines.

Files with missing lines (5)
File Patch % Lines
server.py 0.00% ⚠️ 69 Missing
client.py 0.00% ⚠️ 55 Missing
client.py 0.00% ⚠️ 52 Missing
server.py 0.00% ⚠️ 43 Missing
consts.py 99.48% ⚠️ 2 Missing

Generated by Codecov Action

Comment thread tests/integrations/grpc/test_grpc_aio.py
Comment thread sentry_sdk/integrations/grpc/aio/server.py
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review May 5, 2026 16:01
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner May 5, 2026 16:01
Comment thread sentry_sdk/integrations/grpc/aio/client.py Outdated
Comment thread tests/integrations/grpc/test_grpc_aio.py
Comment thread tests/integrations/grpc/test_grpc_aio.py Outdated
Comment thread tests/integrations/grpc/test_grpc_aio.py Outdated
@alexander-alderman-webb alexander-alderman-webb marked this pull request as draft May 6, 2026 10:35
Comment thread tests/integrations/grpc/test_grpc_aio.py
Comment thread tests/integrations/grpc/test_grpc_aio.py
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review May 6, 2026 14:43
Copy link
Copy Markdown
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

LGTM. Can you please also add parent_span=None to sentry_sdk.traces.start_span calls where there were transactions previously? 🙏🏻

Comment thread tests/integrations/grpc/test_grpc.py Outdated
Comment thread tests/integrations/grpc/test_grpc.py
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 a164341. Configure here.

Comment thread sentry_sdk/integrations/grpc/server.py Outdated
@alexander-alderman-webb alexander-alderman-webb merged commit 4a56e34 into master May 8, 2026
156 checks passed
@alexander-alderman-webb alexander-alderman-webb deleted the webb/grpc/span-first branch May 8, 2026 12:12
Sign up for free to 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 grpc to span first

2 participants