fix(redis): build ClusterPipeline span metadata from _execution_strategy in redis-py 6+#4728
fix(redis): build ClusterPipeline span metadata from _execution_strategy in redis-py 6+#4728UTKARSH698 wants to merge 10 commits into
Conversation
…egy in redis-py 6+ redis-py 6 refactored ClusterPipeline so that queued commands are no longer appended to `command_stack`; they now live on `_execution_strategy.command_queue`. As a result the redis instrumentor emitted ClusterPipeline spans with an empty DB_STATEMENT and a `db.redis.pipeline_length` of 0. `_build_span_meta_data_for_pipeline` now reads commands from `_execution_strategy.command_queue` when present, falling back to `command_stack` / `_command_stack` for non-cluster pipelines and older redis-py versions. Fixes open-telemetry#4084
|
Friendly ping on this one 👋 CI is green and the CLA is signed. This fixes the ClusterPipeline span metadata regression in redis-py 6+ (#4084). Happy to rebase or address any review feedback whenever a maintainer has a chance to take a look — thanks! |
tammy-baylis-swi
left a comment
There was a problem hiding this comment.
Lgtm, maintainers will also have a look. I merged main in to get ci/cd to pass.
…data Exercises a real RedisCluster pipeline and asserts the redis-py 6+ code path (command_stack empty, _execution_strategy.command_queue populated) is genuinely hit before checking the emitted span statement and db.redis.pipeline_length. Guards against regression open-telemetry#4084.
|
Thanks @xrmx — good call. I've added a docker test that exercises the real It asserts the redis-py 6+ code path is genuinely hit ( The nearby |
Thanks for adding the test, you also need to bump redis-py in |
|
Thanks @tammy-baylis-swi and @xrmx for the reviews and approvals 🙏 I've just updated the branch to the latest |
You have missed my previous message:
Also no need to pull latest main, we'll take care of it. |
…ion test exercises the redis-py 6+ code path
|
Thanks @xrmx, and apologies for missing that earlier — you're right. I've bumped |
docker tests are failing, you can run these on your machine with |
redis-py 6.x renamed redis.commands.search.indexDefinition to index_definition (snake_case). The camelCase module was removed, so bumping redis to 6.4.0 broke collection of the entire redis functional test module. IndexDefinition/IndexType are unchanged in the new module.
|
Thanks @xrmx — traced it from the CI log. The |
…_queue The redis-py 6+ sync cluster strategy exposes queued commands via a public command_queue property, but the async cluster strategy only exposes the private _command_queue attribute. Reading only command_queue left the async ClusterPipeline span with an empty statement and a default "redis" name once the docker tests were bumped to redis-py 6.4.0. Resolve _command_queue as a fallback so both sync and async cluster pipelines populate span metadata.
Head branch was pushed to by a user without write access
|
Traced the remaining Root cause: redis-py 6+ exposes the queued commands differently per flavor. The sync cluster strategy ( Fixed in b3ee726 by resolving |
|
@UTKARSH698 have you run the docker-tests locally? |
Description
redis-py 6 refactored
ClusterPipelineso that queued commands are no longer appended tocommand_stack(which still exists but stays empty); they are now tracked on_execution_strategy.command_queue. Because_build_span_meta_data_for_pipelineread commands fromcommand_stack,ClusterPipelinespans under redis-py 6+ were emitted with an emptydb.statementand adb.redis.pipeline_lengthof 0.This change makes
_build_span_meta_data_for_pipelineread commands from_execution_strategy.command_queuewhen present, falling back tocommand_stack/_command_stackfor non-cluster pipelines and older redis-py versions.This revives the approach from #4436 (closed by the stale bot for inactivity after a maintainer reviewed it positively) and adds the changelog fragment via towncrier.
Fixes #4084
Type of change
How Has This Been Tested?
TestBuildSpanMetaDataForPipelineunit tests covering the redis-py 6+ cluster pipeline path (commands read from_execution_strategy.command_queue), a regression test for the legacycommand_stackpath, and the empty-pipeline fallback to aredisspan name.pytestforopentelemetry-instrumentation-redis).ruff checkandruff format --checkclean.Does This PR Require a Contrib Repo Change?
Checklist: