From 4dfc9271cc98f1bdbbf4bf2f88c8c0784777a75b Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Fri, 6 Dec 2024 17:19:21 +0000 Subject: [PATCH] Disable and enable instrumentation on create. --- .../test/pg-pool.test.ts | 10 +++++++--- .../opentelemetry-instrumentation-pg/test/pg.test.ts | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts b/plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts index f0ac1508d9..6347b4aa0d 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts @@ -114,6 +114,10 @@ describe('pg-pool', () => { function create(config: PgInstrumentationConfig = {}) { instrumentation.setConfig(config); instrumentation.enable(); + + // Disable and enable the instrumentation to visit unwrap calls + instrumentation.disable(); + instrumentation.enable(); } let pool: pgPool; @@ -540,7 +544,7 @@ describe('pg-pool', () => { ); assert.strictEqual( metrics[1].dataPoints[0].attributes[ - ATTR_DB_CLIENT_CONNECTION_STATE + ATTR_DB_CLIENT_CONNECTION_STATE ], 'used' ); @@ -551,7 +555,7 @@ describe('pg-pool', () => { ); assert.strictEqual( metrics[1].dataPoints[1].attributes[ - ATTR_DB_CLIENT_CONNECTION_STATE + ATTR_DB_CLIENT_CONNECTION_STATE ], 'idle' ); @@ -764,7 +768,7 @@ describe('pg-pool', () => { ); assert.strictEqual( metrics[1].dataPoints[0].attributes[ - ATTR_DB_CLIENT_CONNECTION_STATE + ATTR_DB_CLIENT_CONNECTION_STATE ], 'used' ); diff --git a/plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts b/plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts index ecb9e6c7fd..adba2e072c 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts @@ -108,6 +108,10 @@ describe('pg', () => { function create(config: PgInstrumentationConfig = {}) { instrumentation.setConfig(config); instrumentation.enable(); + + // Disable and enable the instrumentation to visit unwrap calls + instrumentation.disable(); + instrumentation.enable(); } let postgres: typeof pg;