From bd89bccf60e1d611330c841288ae692d88620310 Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Thu, 5 Dec 2024 19:09:52 +0000 Subject: [PATCH] Guard against undefined. --- .../src/instrumentation.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts index a78029ce00..abdbed59b1 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts @@ -152,11 +152,15 @@ export class PgInstrumentation extends InstrumentationBase { - this._patchPgClient(module.Client); + const moduleExports = extractModuleExports(module); + + this._patchPgClient(moduleExports.Client); return module; }, (module: any) => { - this._unpatchPgClient(module.Client); + const moduleExports = extractModuleExports(module); + + this._unpatchPgClient(moduleExports.Client); return module; }, [modulePgClient, modulePgNativeClient] @@ -187,6 +191,10 @@ export class PgInstrumentation extends InstrumentationBase