feat(redis): Support streaming spans #6083
3 issues
code-review: Found 3 issues (2 medium, 1 low)
Medium
Spans not closed when Redis command raises exception - `sentry_sdk/integrations/redis/_async_common.py:145-152`
In _sentry_execute_command, if old_execute_command raises an exception at line 150, neither db_span.__exit__() (line 152) nor cache_span.__exit__() (line 156) will be called. This leaves spans unclosed, potentially causing them to never be sent to Sentry and potentially leaving scope state corrupted. The spans should be wrapped in try/finally blocks to ensure proper cleanup.
Incorrect span index in assertion checks wrong span's data - `tests/integrations/redis/test_redis_cache_module_async.py:293`
Line 293 asserts "cache.hit" not in spans[1]["data"] but the surrounding context is testing spans[2] (the cache.put span). This assertion inadvertently checks the db.redis span at index 1 instead of the cache.put span at index 2, making the test less meaningful as it doesn't verify the expected span's attributes.
Also found at:
tests/integrations/redis/test_redis_cache_module.py:330
Low
send_default_pii parameter not verified in span_streaming test path - `tests/integrations/redis/asyncio/test_redis_asyncio.py:66-89`
In test_async_redis_pipeline, when span_streaming=True, the send_default_pii parameter is passed to sentry_init but the streaming branch makes no assertions related to PII filtering behavior. The expected_first_ten parameter (which validates PII filtering of command arguments) is completely ignored in the streaming path. This means PII filtering in streaming mode is not being tested, only whether spans are created with correct attributes.
Duration: 3m 9s · Tokens: 2.5M in / 31.1k out · Cost: $3.81 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.01)
Annotations
Check warning on line 152 in sentry_sdk/integrations/redis/_async_common.py
sentry-warden / warden: code-review
Spans not closed when Redis command raises exception
In `_sentry_execute_command`, if `old_execute_command` raises an exception at line 150, neither `db_span.__exit__()` (line 152) nor `cache_span.__exit__()` (line 156) will be called. This leaves spans unclosed, potentially causing them to never be sent to Sentry and potentially leaving scope state corrupted. The spans should be wrapped in try/finally blocks to ensure proper cleanup.
Check warning on line 293 in tests/integrations/redis/test_redis_cache_module_async.py
sentry-warden / warden: code-review
Incorrect span index in assertion checks wrong span's data
Line 293 asserts `"cache.hit" not in spans[1]["data"]` but the surrounding context is testing `spans[2]` (the cache.put span). This assertion inadvertently checks the db.redis span at index 1 instead of the cache.put span at index 2, making the test less meaningful as it doesn't verify the expected span's attributes.
Check warning on line 330 in tests/integrations/redis/test_redis_cache_module.py
sentry-warden / warden: code-review
[PMW-34Y] Incorrect span index in assertion checks wrong span's data (additional location)
Line 293 asserts `"cache.hit" not in spans[1]["data"]` but the surrounding context is testing `spans[2]` (the cache.put span). This assertion inadvertently checks the db.redis span at index 1 instead of the cache.put span at index 2, making the test less meaningful as it doesn't verify the expected span's attributes.