Skip to content

Commit bd89bcc

Browse files
authored
Guard against undefined.
1 parent d3bf605 commit bd89bcc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,15 @@ export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConf
152152
'pg',
153153
SUPPORTED_PG_VERSIONS,
154154
(module: any) => {
155-
this._patchPgClient(module.Client);
155+
const moduleExports = extractModuleExports(module);
156+
157+
this._patchPgClient(moduleExports.Client);
156158
return module;
157159
},
158160
(module: any) => {
159-
this._unpatchPgClient(module.Client);
161+
const moduleExports = extractModuleExports(module);
162+
163+
this._unpatchPgClient(moduleExports.Client);
160164
return module;
161165
},
162166
[modulePgClient, modulePgNativeClient]
@@ -187,6 +191,10 @@ export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConf
187191
}
188192

189193
private _patchPgClient(module: any) {
194+
if (!module) {
195+
return;
196+
}
197+
190198
const moduleExports = extractModuleExports(module);
191199

192200
if (isWrapped(moduleExports.prototype.query)) {

0 commit comments

Comments
 (0)