Skip to content

fix(instrumentation-redis-4): avoid shimmer warning by only wrapping multi/MULTI if they exist #1729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,31 @@ export class RedisInstrumentation extends InstrumentationBase<any> {
this._diag.debug('Patching redis client');
const redisClientPrototype = moduleExports?.default?.prototype;

if (isWrapped(redisClientPrototype?.multi)) {
this._unwrap(redisClientPrototype, 'multi');
// In some @redis/client versions 'multi' is a method. In later
// versions, as of https://github.com/redis/node-redis/pull/2324,
// 'MULTI' is a method and 'multi' is a property defined in the
// constructor that points to 'MULTI', and therefore it will not
// be defined on the prototype.
if (redisClientPrototype?.multi) {
if (isWrapped(redisClientPrototype?.multi)) {
this._unwrap(redisClientPrototype, 'multi');
}
this._wrap(
redisClientPrototype,
'multi',
this._getPatchRedisClientMulti()
);
}
this._wrap(
redisClientPrototype,
'multi',
this._getPatchRedisClientMulti()
);

if (isWrapped(redisClientPrototype?.MULTI)) {
this._unwrap(redisClientPrototype, 'MULTI');
if (redisClientPrototype?.MULTI) {
if (isWrapped(redisClientPrototype?.MULTI)) {
this._unwrap(redisClientPrototype, 'MULTI');
}
this._wrap(
redisClientPrototype,
'MULTI',
this._getPatchRedisClientMulti()
);
}
this._wrap(
redisClientPrototype,
'MULTI',
this._getPatchRedisClientMulti()
);

if (isWrapped(redisClientPrototype?.sendCommand)) {
this._unwrap(redisClientPrototype, 'sendCommand');
Expand Down