Skip to content

Commit 9582a48

Browse files
fix(redis): Use command_queue instead of command_stack if available (#4404)
This [commit](redis/redis-py@91be4a0) in `redis-py` moved away from using the Pipeline's `command_stack` and is now using `_execution_strategy.command_queue` instead. We need to adapt to use the new command source if present. This fixes `redis-latest` in CI. --------- Co-authored-by: Daniel Szoke <[email protected]>
1 parent ac7646b commit 9582a48

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

sentry_sdk/integrations/redis/_sync_common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,19 @@ def sentry_patched_execute(self, *args, **kwargs):
4242
origin=SPAN_ORIGIN,
4343
) as span:
4444
with capture_internal_exceptions():
45+
command_seq = None
46+
try:
47+
command_seq = self._execution_strategy.command_queue
48+
except AttributeError:
49+
command_seq = self.command_stack
50+
4551
set_db_data_fn(span, self)
4652
_set_pipeline_data(
4753
span,
4854
is_cluster,
4955
get_command_args_fn,
5056
False if is_cluster else self.transaction,
51-
self.command_stack,
57+
command_seq,
5258
)
5359

5460
return old_execute(self, *args, **kwargs)

sentry_sdk/integrations/redis/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,18 @@ def _parse_rediscluster_command(command):
106106

107107

108108
def _set_pipeline_data(
109-
span, is_cluster, get_command_args_fn, is_transaction, command_stack
109+
span,
110+
is_cluster,
111+
get_command_args_fn,
112+
is_transaction,
113+
commands_seq,
110114
):
111115
# type: (Span, bool, Any, bool, Sequence[Any]) -> None
112116
span.set_tag("redis.is_cluster", is_cluster)
113117
span.set_tag("redis.transaction", is_transaction)
114118

115119
commands = []
116-
for i, arg in enumerate(command_stack):
120+
for i, arg in enumerate(commands_seq):
117121
if i >= _MAX_NUM_COMMANDS:
118122
break
119123

@@ -123,7 +127,7 @@ def _set_pipeline_data(
123127
span.set_data(
124128
"redis.commands",
125129
{
126-
"count": len(command_stack),
130+
"count": len(commands_seq),
127131
"first_ten": commands,
128132
},
129133
)

0 commit comments

Comments
 (0)