Skip to content

feat(pymongo): Add span streaming support#6253

Open
ericapisani wants to merge 3 commits into
masterfrom
py-2349-migrate-pymongo
Open

feat(pymongo): Add span streaming support#6253
ericapisani wants to merge 3 commits into
masterfrom
py-2349-migrate-pymongo

Conversation

@ericapisani
Copy link
Copy Markdown
Member

@ericapisani ericapisani commented May 11, 2026

Add span streaming support to the PyMongo integration. The legacy code path is preserved unchanged for non-streaming clients.

Fixes PY-2349
Fixes #6047

Add span streaming support to the PyMongo integration, mirroring the
pattern used in the asyncpg integration. When trace_lifecycle=stream is
enabled, spans are emitted using the new StreamedSpan API with OTel-style
attributes. The legacy code path is preserved for non-streaming clients.

Fixes PY-2349
Fixes #6047
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 11, 2026

PY-2349

@ericapisani
Copy link
Copy Markdown
Member Author

bugbot run

@ericapisani
Copy link
Copy Markdown
Member Author

@sentry review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Codecov Results 📊

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

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 6.67%. Project has 14358 uncovered lines.
❌ Project coverage is 34.94%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
pymongo.py 10.29% ⚠️ 122 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    34.96%    34.94%    -0.02%
==========================================
  Files          190       190         —
  Lines        22052     22069       +17
  Branches      7408      7420       +12
==========================================
+ Hits          7709      7711        +2
- Misses       14343     14358       +15
- Partials       807       807         —

Generated by Codecov Action

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 b8ddc07. Configure here.

Comment thread sentry_sdk/integrations/pymongo.py

data: "Dict[str, Any]" = {"operation_ids": {}}
data["operation_ids"]["operation"] = event.operation_id
data["operation_ids"]["request"] = event.request_id
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are also kept for legacy reasons, are being removed for streamed spans.

@ericapisani ericapisani marked this pull request as ready for review May 11, 2026 18:46
@ericapisani ericapisani requested a review from a team as a code owner May 11, 2026 18:46
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 pymongo to span first

1 participant