fix(redis): build ClusterPipeline span metadata from _execution_strategy in redis-py 6+#4728
Open
UTKARSH698 wants to merge 2 commits into
Open
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: