Skip to content

feat(asyncpg): Add span streaming support#6215

Open
ericapisani wants to merge 5 commits intomasterfrom
py-2305-migrate-asyncpg
Open

feat(asyncpg): Add span streaming support#6215
ericapisani wants to merge 5 commits intomasterfrom
py-2305-migrate-asyncpg

Conversation

@ericapisani
Copy link
Copy Markdown
Member

@ericapisani ericapisani commented May 6, 2026

Migrates the asyncpg integration to support the stream trace lifecycle.

The integration now uses record_sql_queries_supporting_streaming and StreamedSpan so that DB spans are emitted as soon as they complete rather than being buffered until transaction end.

Tests are parameterized over both span_streaming=True and span_streaming=False to verify both paths.

Fixes PY-2305, fixes #6003

Migrates the asyncpg integration to use `record_sql_queries_supporting_streaming` and `StreamedSpan`, adding support for the `stream` trace lifecycle. Tests are parameterized to cover both static and streaming modes.

Fixes PY-2305
Fixes #6003
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 6, 2026

@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 6, 2026

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 8.06s

All tests are passing successfully.

❌ Patch coverage is 8.16%. Project has 15155 uncovered lines.

Files with missing lines (1)
File Patch % Lines
asyncpg.py 10.87% ⚠️ 123 Missing

Generated by Codecov Action

Comment thread sentry_sdk/integrations/asyncpg.py
Comment thread sentry_sdk/integrations/asyncpg.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 2 potential issues.

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

Comment thread sentry_sdk/integrations/asyncpg.py Outdated
Comment thread sentry_sdk/integrations/asyncpg.py
…an has been created. This allows the traces_sampler to see the attributes and make decisions based on them
Comment thread sentry_sdk/integrations/asyncpg.py
@ericapisani ericapisani marked this pull request as ready for review May 8, 2026 18:10
@ericapisani ericapisani requested a review from a team as a code owner May 8, 2026 18:10
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.

To keep the amount of changes within this pull request under control, I've separated out a number of clean up changes related to the tests in the other pull request.

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 asyncpg to span first

2 participants