feat(redis): Support streaming spans #6083
3 issues
code-review: Found 3 issues (1 medium, 2 low)
Medium
Test assertion checks wrong span index - `tests/integrations/redis/test_redis_cache_module_async.py:293`
Line 293 asserts "cache.hit" not in spans[1]["data"] but spans[1] is a db.redis span (as confirmed by line 286), not the cache.put span. The assertion should check spans[2] to properly verify that cache.put operations don't have a cache.hit attribute. This bug makes the test less effective since it's not validating the intended behavior.
Also found at:
tests/integrations/redis/test_redis_cache_module.py:330
Low
Unnecessary computation of commands list for StreamedSpan - `sentry_sdk/integrations/redis/utils.py:119-125`
The commands list is built by iterating over commands_seq (up to _MAX_NUM_COMMANDS items) and calling get_command_args_fn and _get_safe_command on each. However, when span is a StreamedSpan, this list is never used since the span.set_data call is skipped. This causes unnecessary CPU cycles for every Redis pipeline execution in streaming mode.
Test parameter `expected_first_ten` unused in span_streaming path creates redundant test runs - `tests/integrations/redis/cluster/test_redis_cluster.py:146-155`
The expected_first_ten parameter is only used in the non-streaming branch (lines 205-210), but the test is parameterized with @pytest.mark.parametrize("span_streaming", [True, False]) combined with the expected_first_ten parametrization. This creates 4 test cases when only 3 are meaningful (2 for static + 1 for streaming), resulting in redundant test execution for span_streaming=True.
Duration: 8m 55s · Tokens: 2.9M in / 33.5k out · Cost: $4.01 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.01)
Annotations
Check warning on line 293 in tests/integrations/redis/test_redis_cache_module_async.py
sentry-warden / warden: code-review
Test assertion checks wrong span index
Line 293 asserts `"cache.hit" not in spans[1]["data"]` but `spans[1]` is a `db.redis` span (as confirmed by line 286), not the `cache.put` span. The assertion should check `spans[2]` to properly verify that cache.put operations don't have a `cache.hit` attribute. This bug makes the test less effective since it's not validating the intended behavior.
Check warning on line 330 in tests/integrations/redis/test_redis_cache_module.py
sentry-warden / warden: code-review
[JP9-76T] Test assertion checks wrong span index (additional location)
Line 293 asserts `"cache.hit" not in spans[1]["data"]` but `spans[1]` is a `db.redis` span (as confirmed by line 286), not the `cache.put` span. The assertion should check `spans[2]` to properly verify that cache.put operations don't have a `cache.hit` attribute. This bug makes the test less effective since it's not validating the intended behavior.