Skip to content

Commit 404111a

Browse files
committed
fix(redis): resolved pool instrumentation to use instance instead of prototype
The instrumentation for pool was returning the prototype instead of the instance, which is wrong and will broke private-field access.
1 parent 068c016 commit 404111a

File tree

1 file changed

+7
-9
lines changed
  • packages/core/src/tracing/instrumentation/databases

1 file changed

+7
-9
lines changed

packages/core/src/tracing/instrumentation/databases/redis.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,17 @@ function instrument(redis) {
131131
};
132132
};
133133

134-
const creatPoolWrap = originalCreatePool => {
134+
const createPoolWrap = originalCreatePool => {
135135
return function instrumentedCreateRedisPool(poolOptions) {
136136
const redisPoolInstance = originalCreatePool.apply(this, arguments);
137137
const redisUrl = poolOptions?.url;
138-
const redisPoolPrototype = Object.getPrototypeOf(redisPoolInstance);
139138

140-
shimAllCommands(redisPoolPrototype, redisUrl, false, redisCommandList);
139+
shimAllCommands(redisPoolInstance, redisUrl, false, redisCommandList);
141140

142-
if (typeof redisPoolPrototype.multi === 'function') {
143-
shimmer.wrap(redisPoolPrototype, 'multi', wrapMulti(redisUrl, false));
141+
if (typeof redisPoolInstance.multi === 'function') {
142+
shimmer.wrap(redisPoolInstance, 'multi', wrapMulti(redisUrl, false));
144143
}
145-
146-
return redisPoolPrototype;
144+
return redisPoolInstance;
147145
};
148146
};
149147

@@ -191,11 +189,11 @@ function instrument(redis) {
191189
configurable: true,
192190
enumerable: true,
193191
get() {
194-
return creatPoolWrap(poolDescriptor.get.call(this));
192+
return createPoolWrap(poolDescriptor.get.call(this));
195193
}
196194
});
197195
} else {
198-
shimmer.wrap(redis, 'createClientPool', creatPoolWrap);
196+
shimmer.wrap(redis, 'createClientPool', createPoolWrap);
199197
}
200198
}
201199
};

0 commit comments

Comments
 (0)