Skip to content

fix(instrumentation-redis): add spans for cluster multi/transaction commands #3427

Open
Renegade2345 wants to merge 6 commits intoopen-telemetry:mainfrom
Renegade2345:fix/redis-cluster-multi-command-spans
Open

fix(instrumentation-redis): add spans for cluster multi/transaction commands #3427
Renegade2345 wants to merge 6 commits intoopen-telemetry:mainfrom
Renegade2345:fix/redis-cluster-multi-command-spans

Conversation

@Renegade2345
Copy link
Copy Markdown
Contributor

Which problem is this PR solving?

When using createCluster (Redis cluster mode), commands run inside multi().exec() transactions do not produce OpenTelemetry spans. The same commands work correctly with createClient (standalone mode).
Fixes #3369

Short description of the changes

The existing instrumentation only patches the standalone Redis client's
multi-command module (client/multi-command.js). The cluster client uses
a separate multi-command class (cluster/multi-command.js) with a
different addCommand signature: (firstKey, isReadonly, args, transformReply)
vs the standalone (args).

This PR adds instrumentation for two additional module files:

  • cluster/index.js — patches MULTI to store cluster options on the
    returned multi command object, so connection attributes are available
    when creating spans
  • cluster/multi-command.js — patches addCommand and exec to create
    spans for each command in the transaction, mirroring the existing
    standalone client patching

A new test file test/v4-v5/redis.cluster.test.ts is added with tests
that require a live Redis cluster (gated behind RUN_REDIS_CLUSTER_TESTS
env var), covering:

  • multi().exec() transaction commands producing spans
  • multi().addCommand([...]).exec() generic command spans
  • Error handling in cluster multi commands
  • Regular cluster commands still producing spans

@Renegade2345 Renegade2345 requested a review from a team as a code owner March 12, 2026 06:45
@github-actions github-actions bot added pkg:instrumentation-knex pkg:instrumentation-redis pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found. labels Mar 12, 2026
@github-actions github-actions bot requested a review from blumamir March 12, 2026 06:45
@github-actions
Copy link
Copy Markdown
Contributor

This package does not have an assigned component owner and is considered unmaintained. As such this package is in feature-freeze and this PR will be closed with 14 days unless a new owner or a sponsor (a member of @open-telemetry/javascript-approvers) for the feature is found. It is the responsibility of the author to find a sponsor for this feature.
Are you familiar with this package? Consider becoming a component owner.

…ommands

When using createCluster, commands run inside multi().exec() were not
producing spans. This fix patches cluster/index.js to store options
on the multi command object, and cluster/multi-command.js to wrap
addCommand and exec, mirroring the existing standalone client patching.
Fixes open-telemetry#3369
@Renegade2345 Renegade2345 force-pushed the fix/redis-cluster-multi-command-spans branch from 3a97f93 to b25ba8d Compare March 12, 2026 06:51
@Renegade2345 Renegade2345 changed the title Fix/redis cluster multi command spans fix(instrumentation-redis): add spans for cluster multi/transaction commands Mar 12, 2026
@Renegade2345
Copy link
Copy Markdown
Contributor Author

Hey @blumamir, when you have time could you please review the changes? Any suggestions, corrections are more than welcome. Thanks!

@Renegade2345
Copy link
Copy Markdown
Contributor Author

Hi @blumamir, could you please approve the workflow runs when you get a chance? Happy to make any changes if needed. Thanks!

@Renegade2345
Copy link
Copy Markdown
Contributor Author

Hi @david-luna ,

Apologies for the ping, I wanted to follow up on this PR since it’s been open for a couple of weeks.
Since this package is currently unmaintained and the PR is at risk of auto-closing, could you please:

  • Take a quick look if possible
  • Approve the workflows so CI can run

Happy to make any changes or adjustments needed. Thanks a lot!

@david-luna
Copy link
Copy Markdown
Contributor

@Renegade2345

Sorry I won't have the bandwith this week to have a look but I can give sponsorship and review the next one.

@david-luna david-luna added the has:sponsor This package or feature has a sponsor that has volunteered to review PRs and respond to questions label Mar 31, 2026
@Renegade2345
Copy link
Copy Markdown
Contributor Author

No worries at all, completely understand!

Really appreciate you sponsoring this.
I’ll work on addressing the failing checks and improving coverage in the meantime. Happy to incorporate any feedback whenever you get a chance later. Thanks again!

Copy link
Copy Markdown
Contributor

@david-luna david-luna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has:sponsor This package or feature has a sponsor that has volunteered to review PRs and respond to questions pkg:instrumentation-knex pkg:instrumentation-redis pkg-status:unmaintained:autoclose-scheduled pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[instrumentation-redis] Commands run as part of a transaction not showing up when connecting to a cluster

3 participants