feat(asyncpg): Add span streaming support#6215
Conversation
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
|
bugbot run |
|
@sentry review |
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)
Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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.
…an has been created. This allows the traces_sampler to see the attributes and make decisions based on them
There was a problem hiding this comment.
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.
sentrivana
left a comment
There was a problem hiding this comment.
Looking great! See one comment.
| ) as span: | ||
| _set_db_data(span, args[0]) | ||
| res = f(*args, **kwargs) | ||
| span.set_data("db.cursor", res) |
There was a problem hiding this comment.
I know we're not porting this to streamed spans, which is 💯 the right call, but are we removing it for legacy spans, too? I'd keep it in the old path, to reduce the odds of breaking a user. We'll anyway get rid of this in the next major when span streaming is the default.
There was a problem hiding this comment.
are we removing it for legacy spans, too?
We aren't 👍🏻
It's non-obvious from this diff, but because we're calling _record on line 147, and it calls record_sql_queries_supporting_streaming, this is still getting set for legacy spans

Migrates the asyncpg integration to support the
streamtrace lifecycle.The integration now uses
record_sql_queries_supporting_streamingandStreamedSpanso that DB spans are emitted as soon as they complete rather than being buffered until transaction end.Tests are parameterized over both
span_streaming=Trueandspan_streaming=Falseto verify both paths.Fixes PY-2305, fixes #6003