Skip to content

.

3869fad
Select commit
Loading
Failed to load commit list.
Merged

feat(redis): Support streaming spans #6083

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

3 issues

code-review: Found 3 issues (3 medium)

Medium

Spans not closed on Redis command exception - `sentry_sdk/integrations/redis/_async_common.py:145-158`

When old_execute_command raises an exception (e.g., Redis connection error), db_span.__exit__() and cache_span.__exit__() are never called because they're not wrapped in a try/finally block. This causes span leaks where spans remain open without proper cleanup. Other integrations like graphene.py correctly use try/finally to ensure __exit__ is always called.

Also found at:

  • sentry_sdk/integrations/redis/_sync_common.py:151-152
Test parameter 'expected_first_ten' is unused when span_streaming=True - `tests/integrations/redis/cluster/test_redis_cluster.py:152-153`

The expected_first_ten parameter is defined via @pytest.mark.parametrize but is only used in the else branch (non-streaming path) at line 207. When span_streaming=True, this parameter is accepted but never asserted, meaning the test doesn't verify that command filtering works correctly in streaming mode. This creates a false sense of test coverage for the send_default_pii feature in the streaming path.

Also found at:

  • tests/integrations/redis/test_redis.py:72-90
Test asserts wrong span index for cache.hit check - `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 typo where spans[1] should be spans[2]. As written, the test may pass incorrectly if spans[1] (db.redis) happens to not have cache.hit, even if spans[2] incorrectly contains it.

Also found at:

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

Duration: 3m 53s · Tokens: 2.3M in / 30.7k out · Cost: $3.46 (+merge: $0.00, +fix_gate: $0.00)

Annotations

Check warning on line 158 in sentry_sdk/integrations/redis/_async_common.py

See this annotation in the file changed.

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

Spans not closed on Redis command exception

When `old_execute_command` raises an exception (e.g., Redis connection error), `db_span.__exit__()` and `cache_span.__exit__()` are never called because they're not wrapped in a try/finally block. This causes span leaks where spans remain open without proper cleanup. Other integrations like `graphene.py` correctly use try/finally to ensure `__exit__` is always called.

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

See this annotation in the file changed.

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

[MBV-XFM] Spans not closed on Redis command exception (additional location)

When `old_execute_command` raises an exception (e.g., Redis connection error), `db_span.__exit__()` and `cache_span.__exit__()` are never called because they're not wrapped in a try/finally block. This causes span leaks where spans remain open without proper cleanup. Other integrations like `graphene.py` correctly use try/finally to ensure `__exit__` is always called.

Check warning on line 153 in tests/integrations/redis/cluster/test_redis_cluster.py

See this annotation in the file changed.

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

Test parameter 'expected_first_ten' is unused when span_streaming=True

The `expected_first_ten` parameter is defined via `@pytest.mark.parametrize` but is only used in the `else` branch (non-streaming path) at line 207. When `span_streaming=True`, this parameter is accepted but never asserted, meaning the test doesn't verify that command filtering works correctly in streaming mode. This creates a false sense of test coverage for the `send_default_pii` feature in the streaming path.

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

See this annotation in the file changed.

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

[SHK-SEL] Test parameter 'expected_first_ten' is unused when span_streaming=True (additional location)

The `expected_first_ten` parameter is defined via `@pytest.mark.parametrize` but is only used in the `else` branch (non-streaming path) at line 207. When `span_streaming=True`, this parameter is accepted but never asserted, meaning the test doesn't verify that command filtering works correctly in streaming mode. This creates a false sense of test coverage for the `send_default_pii` feature in the streaming path.

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

Test asserts wrong span index for cache.hit check

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 typo where `spans[1]` should be `spans[2]`. As written, the test may pass incorrectly if spans[1] (db.redis) happens to not have cache.hit, even if spans[2] incorrectly contains it.

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

[K75-APM] Test asserts wrong span index for cache.hit check (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 typo where `spans[1]` should be `spans[2]`. As written, the test may pass incorrectly if spans[1] (db.redis) happens to not have cache.hit, even if spans[2] incorrectly contains it.