fix(instrumentation-redis): add spans for cluster multi/transaction commands #3427
fix(instrumentation-redis): add spans for cluster multi/transaction commands #3427Renegade2345 wants to merge 6 commits intoopen-telemetry:mainfrom
Conversation
|
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. |
…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
3a97f93 to
b25ba8d
Compare
|
Hey @blumamir, when you have time could you please review the changes? Any suggestions, corrections are more than welcome. Thanks! |
|
Hi @blumamir, could you please approve the workflow runs when you get a chance? Happy to make any changes if needed. Thanks! |
|
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.
Happy to make any changes or adjustments needed. Thanks a lot! |
|
Sorry I won't have the bandwith this week to have a look but I can give sponsorship and review the next one. |
|
No worries at all, completely understand! Really appreciate you sponsoring this. |
…ests for coverage
Which problem is this PR solving?
When using
createCluster(Redis cluster mode), commands run insidemulti().exec()transactions do not produce OpenTelemetry spans. The same commands work correctly withcreateClient(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 usesa separate multi-command class (
cluster/multi-command.js) with adifferent
addCommandsignature:(firstKey, isReadonly, args, transformReply)vs the standalone
(args).This PR adds instrumentation for two additional module files:
cluster/index.js— patchesMULTIto store cluster options on thereturned multi command object, so connection attributes are available
when creating spans
cluster/multi-command.js— patchesaddCommandandexecto createspans for each command in the transaction, mirroring the existing
standalone client patching
A new test file
test/v4-v5/redis.cluster.test.tsis added with teststhat require a live Redis cluster (gated behind
RUN_REDIS_CLUSTER_TESTSenv var), covering:
multi().exec()transaction commands producing spansmulti().addCommand([...]).exec()generic command spans