dd-trace-py icon indicating copy to clipboard operation
dd-trace-py copied to clipboard

[BUG]: Incompatibility with `redis-py 6.2.0`: Removed `_command_stack` breaks `ddtrace` async patching

Open kangadrewie opened this issue 6 months ago • 0 comments

Tracer Version(s)

latest

Python Version(s)

Python3 3.11

Pip Version(s)

pip

Bug Report

Hello 👋

The redis-py library recently released version 6.2.0, which introduces support for transactions in AsyncRedisCluster. As part of this update, the internal _command_stack attribute was removed.

However, ddtrace currently patches the pipeline by relying on this now-removed _command_stack attribute. This results in compatibility issues with the latest redis-py release.

Would be great to update the patching logic to support redis-py 6.2.0 and newer.

Reproduction Code

Attempting to run an asyncio pipeline with redis-py version ≥ 6.2.0 while using ddtrace results in an error.

Error Logs

  File "/app/.venv/lib/python3.13/site-packages/ddtrace/contrib/internal/redis/asyncio_patch.py", line 34, in instrumented_async_execute_cluster_pipeline
    cmds = [stringify_cache_args(c.args, cmd_max_len=config.redis.cmd_max_length) for c in instance._command_stack]
                                                                                           ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ClusterPipeline' object has no attribute '_command_stack'

Libraries in Use

redis-py ≥ 6.2.0
ddtrace ≥ main

Operating System

No response

kangadrewie avatar Jun 04 '25 19:06 kangadrewie