Skip to content

.

71308a3
Select commit
Loading
Failed to load commit list.
Merged

feat(redis): Support streaming spans #6083

.
71308a3
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Apr 23, 2026 in 4m 24s

3 issues

code-review: Found 3 issues (3 medium)

Medium

Spans leak when Redis command throws exception - `sentry_sdk/integrations/redis/_sync_common.py:145-156`

In sentry_patched_execute_command, the db_span and cache_span are manually entered via __enter__() but if old_execute_command() raises an exception, the __exit__() calls on lines 152 and 156 are never reached. This causes spans to leak (not be properly closed), the error status to not be recorded on the span, and potentially corrupted scope state for StreamedSpan which tracks _previous_span_on_scope.

Test parameters `is_transaction`, `send_default_pii`, and `expected_first_ten` are unused in the streaming path - `tests/integrations/redis/test_redis.py:72-91`

The test_redis_pipeline function is parametrized with is_transaction, send_default_pii, and expected_first_ten, but when span_streaming=True, these parameters have no effect on the assertions. The streaming branch only asserts on span names, op, origin, and db.system.name, without verifying that different transaction/pii/command formatting behaviors work correctly. This means the streaming path runs multiple parameter combinations but doesn't actually test differentiated behavior, creating a false sense of test coverage.

Also found at:

  • sentry_sdk/integrations/redis/modules/queries.py:54
Assertion checks wrong span index for cache.hit absence - `tests/integrations/redis/test_redis_cache_module_async.py:293`

Line 293 checks spans[1]["data"] for the absence of cache.hit, but the surrounding context is asserting properties of spans[2] (the cache.put span). This appears to be a copy-paste error where the index should be spans[2]["data"] to check that the cache.put operation doesn't have a cache.hit attribute. The test will pass incorrectly if spans[1] (db.redis) happens to not have cache.hit, even if spans[2] has it erroneously.

Also found at:

  • tests/integrations/redis/test_redis_cache_module.py:330

Duration: 4m 16s · Tokens: 2.4M in / 32.5k out · Cost: $3.40 (+merge: $0.00, +fix_gate: $0.00)

Annotations

Check warning on line 156 in sentry_sdk/integrations/redis/_sync_common.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Spans leak when Redis command throws exception

In `sentry_patched_execute_command`, the `db_span` and `cache_span` are manually entered via `__enter__()` but if `old_execute_command()` raises an exception, the `__exit__()` calls on lines 152 and 156 are never reached. This causes spans to leak (not be properly closed), the error status to not be recorded on the span, and potentially corrupted scope state for StreamedSpan which tracks `_previous_span_on_scope`.

Check warning on line 91 in tests/integrations/redis/test_redis.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Test parameters `is_transaction`, `send_default_pii`, and `expected_first_ten` are unused in the streaming path

The `test_redis_pipeline` function is parametrized with `is_transaction`, `send_default_pii`, and `expected_first_ten`, but when `span_streaming=True`, these parameters have no effect on the assertions. The streaming branch only asserts on span names, op, origin, and db.system.name, without verifying that different transaction/pii/command formatting behaviors work correctly. This means the streaming path runs multiple parameter combinations but doesn't actually test differentiated behavior, creating a false sense of test coverage.

Check warning on line 54 in sentry_sdk/integrations/redis/modules/queries.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[3CS-E66] Test parameters `is_transaction`, `send_default_pii`, and `expected_first_ten` are unused in the streaming path (additional location)

The `test_redis_pipeline` function is parametrized with `is_transaction`, `send_default_pii`, and `expected_first_ten`, but when `span_streaming=True`, these parameters have no effect on the assertions. The streaming branch only asserts on span names, op, origin, and db.system.name, without verifying that different transaction/pii/command formatting behaviors work correctly. This means the streaming path runs multiple parameter combinations but doesn't actually test differentiated behavior, creating a false sense of test coverage.

Check warning on line 293 in tests/integrations/redis/test_redis_cache_module_async.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Assertion checks wrong span index for cache.hit absence

Line 293 checks `spans[1]["data"]` for the absence of `cache.hit`, but the surrounding context is asserting properties of `spans[2]` (the cache.put span). This appears to be a copy-paste error where the index should be `spans[2]["data"]` to check that the cache.put operation doesn't have a cache.hit attribute. The test will pass incorrectly if spans[1] (db.redis) happens to not have cache.hit, even if spans[2] has it erroneously.

Check warning on line 330 in tests/integrations/redis/test_redis_cache_module.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[583-4UL] Assertion checks wrong span index for cache.hit absence (additional location)

Line 293 checks `spans[1]["data"]` for the absence of `cache.hit`, but the surrounding context is asserting properties of `spans[2]` (the cache.put span). This appears to be a copy-paste error where the index should be `spans[2]["data"]` to check that the cache.put operation doesn't have a cache.hit attribute. The test will pass incorrectly if spans[1] (db.redis) happens to not have cache.hit, even if spans[2] has it erroneously.