feat(redis): Support streaming spans #6083
3 issues
find-bugs: Found 3 issues (3 medium)
Medium
Spans are never closed when Redis command raises an exception - `sentry_sdk/integrations/redis/_sync_common.py:145-150`
The code manually enters spans using __enter__() (lines 126, 145) and exits them using __exit__(None, None, None) (lines 152, 156), but if old_execute_command() (line 150) raises an exception, the __exit__ calls are never reached. This causes spans to remain open/unfinished, corrupts the scope's current span, and fails to record the error status on the spans.
Test assertion expects wrong value for db.system.name attribute - `tests/integrations/redis/cluster/test_redis_cluster.py:100`
The test asserts attrs["db.system.name"] == "redis-py" but the implementation in sentry_sdk/integrations/redis/modules/queries.py:54 sets span.set_attribute("db.system.name", "redis"). This test will fail at runtime. The value "redis-py" is actually used for DB_DRIVER_NAME, not db.system.name.
Assertion checks wrong span index for cache.hit attribute - `tests/integrations/redis/test_redis_cache_module.py:330`
Line 330 checks spans[1]["data"] for absence of cache.hit, but spans[1] is a db.redis span (confirmed at line 323). The assertion should check spans[2] which is the cache.put span (confirmed at line 325). This causes the test to always pass since db.redis spans never have cache.hit, masking potential bugs where cache.put spans incorrectly include this attribute.
Also found at:
tests/integrations/redis/test_redis_cache_module_async.py:293
Duration: 10m 9s · Tokens: 4.4M in / 42.6k out · Cost: $6.13 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.00)
Annotations
Check warning on line 150 in sentry_sdk/integrations/redis/_sync_common.py
sentry-warden / warden: find-bugs
Spans are never closed when Redis command raises an exception
The code manually enters spans using `__enter__()` (lines 126, 145) and exits them using `__exit__(None, None, None)` (lines 152, 156), but if `old_execute_command()` (line 150) raises an exception, the `__exit__` calls are never reached. This causes spans to remain open/unfinished, corrupts the scope's current span, and fails to record the error status on the spans.
Check warning on line 100 in tests/integrations/redis/cluster/test_redis_cluster.py
sentry-warden / warden: find-bugs
Test assertion expects wrong value for db.system.name attribute
The test asserts `attrs["db.system.name"] == "redis-py"` but the implementation in `sentry_sdk/integrations/redis/modules/queries.py:54` sets `span.set_attribute("db.system.name", "redis")`. This test will fail at runtime. The value `"redis-py"` is actually used for `DB_DRIVER_NAME`, not `db.system.name`.
Check warning on line 330 in tests/integrations/redis/test_redis_cache_module.py
sentry-warden / warden: find-bugs
Assertion checks wrong span index for cache.hit attribute
Line 330 checks `spans[1]["data"]` for absence of `cache.hit`, but `spans[1]` is a `db.redis` span (confirmed at line 323). The assertion should check `spans[2]` which is the `cache.put` span (confirmed at line 325). This causes the test to always pass since db.redis spans never have `cache.hit`, masking potential bugs where cache.put spans incorrectly include this attribute.
Check warning on line 293 in tests/integrations/redis/test_redis_cache_module_async.py
sentry-warden / warden: find-bugs
[88Y-6X3] Assertion checks wrong span index for cache.hit attribute (additional location)
Line 330 checks `spans[1]["data"]` for absence of `cache.hit`, but `spans[1]` is a `db.redis` span (confirmed at line 323). The assertion should check `spans[2]` which is the `cache.put` span (confirmed at line 325). This causes the test to always pass since db.redis spans never have `cache.hit`, masking potential bugs where cache.put spans incorrectly include this attribute.