feat(sqlalchemy): Support span streaming #6132
3 issues
find-bugs: Found 3 issues (1 high, 2 low)
High
StreamedSpan lacks set_data method called in _wrap_cursor_creation - `sentry_sdk/integrations/asyncpg.py:105`
The type annotation change to Iterator[Union[Span, StreamedSpan]] reflects that record_sql_queries can return either type, but line 156 calls span.set_data("db.cursor", res) which will fail with AttributeError when span streaming is enabled. StreamedSpan only has set_attribute(), not set_data(). This causes a runtime crash when using asyncpg cursor operations with span streaming enabled.
Also found at:
sentry_sdk/integrations/asyncpg.py:201-205
Low
Debug print statement left in test fixture - `tests/conftest.py:486`
A print(span) statement on line 486 was left in the code, likely from debugging during development. This will pollute test output with span data for every span processed by render_span_tree(), making test logs noisy and harder to read.
Missing SERVER_ADDRESS assertion in span_streaming=True branch of test_transactions - `tests/integrations/sqlalchemy/test_sqlalchemy.py:162`
In the test_transactions function, the span_streaming=True branch (line 162) only asserts that SPANDATA.SERVER_PORT not in span["attributes"], while the span_streaming=False branch (lines 203-204) asserts both SPANDATA.SERVER_ADDRESS not in span["data"] and SPANDATA.SERVER_PORT not in span["data"]. This inconsistency means the span streaming path has less test coverage and could miss regressions where SERVER_ADDRESS is incorrectly set for in-memory SQLite databases.
Also found at:
tests/integrations/sqlalchemy/test_sqlalchemy.py:293
Duration: 9m 29s · Tokens: 7.0M in / 68.4k out · Cost: $10.58 (+extraction: $0.01, +merge: $0.00, +fix_gate: $0.01)
Annotations
Check failure on line 105 in sentry_sdk/integrations/asyncpg.py
sentry-warden / warden: find-bugs
StreamedSpan lacks set_data method called in _wrap_cursor_creation
The type annotation change to `Iterator[Union[Span, StreamedSpan]]` reflects that `record_sql_queries` can return either type, but line 156 calls `span.set_data("db.cursor", res)` which will fail with AttributeError when span streaming is enabled. StreamedSpan only has `set_attribute()`, not `set_data()`. This causes a runtime crash when using asyncpg cursor operations with span streaming enabled.
Check failure on line 205 in sentry_sdk/integrations/asyncpg.py
sentry-warden / warden: find-bugs
[KAV-9GR] StreamedSpan lacks set_data method called in _wrap_cursor_creation (additional location)
The type annotation change to `Iterator[Union[Span, StreamedSpan]]` reflects that `record_sql_queries` can return either type, but line 156 calls `span.set_data("db.cursor", res)` which will fail with AttributeError when span streaming is enabled. StreamedSpan only has `set_attribute()`, not `set_data()`. This causes a runtime crash when using asyncpg cursor operations with span streaming enabled.