Skip to content

Commit 2968836

Browse files
committed
fix: check existence of functions on prototype instead
1 parent 225289d commit 2968836

File tree

1 file changed

+3
-1
lines changed
  • plugins/node/opentelemetry-instrumentation-mysql2/src

1 file changed

+3
-1
lines changed

plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ export function getConnectionPrototypeToInstrument(connection: any) {
153153

154154
// [email protected] included a refactoring, where most code was moved out of the `Connection` class and into a shared base
155155
// so we need to instrument that instead, see https://github.com/sidorares/node-mysql2/pull/3081
156-
if (basePrototype?.constructor?.name === 'BaseConnection') {
156+
// This checks if the functions we're instrumenting are there on the base - we cannot use the presence of a base
157+
// prototype since EventEmitter is the base for mysql2@<=3.11.4
158+
if (typeof basePrototype?.query === 'function' && typeof basePrototype?.execute === 'function') {
157159
return basePrototype;
158160
}
159161

0 commit comments

Comments
 (0)