Skip to content

Commit b5b72ec

Browse files
committed
fix(instr-mysql2): fix how prototype is extracted
1 parent 2267454 commit b5b72ec

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,12 @@ export class MySQL2Instrumentation extends InstrumentationBase<MySQL2Instrumenta
215215
private _getConnectionPrototype(moduleExports: any): mysqlTypes.Connection {
216216
const baseClass = Object.getPrototypeOf(moduleExports.Connection);
217217

218-
// if `baseClass` has no prototype means connection is not extending
219-
// another class so the functions we need to patch are already there
220-
if (typeof baseClass.prototype === 'undefined') {
221-
return moduleExports.Connection.prototype;
218+
// return the base class prototype if it has the method
219+
// we need to patch ([email protected]+)
220+
if (typeof baseClass.prototype?.query === 'function') {
221+
return baseClass.prototype;
222222
}
223223

224-
// return the BaseConnection prototype ([email protected]+)
225-
return baseClass.prototype;
224+
return moduleExports.Connection.prototype;
226225
}
227226
}

0 commit comments

Comments
 (0)