Skip to content

Commit

Permalink
Disable and enable instrumentation on create.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Dec 6, 2024
1 parent 76cefbb commit 4dfc927
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<pg.Client>;
Expand Down Expand Up @@ -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'
);
Expand All @@ -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'
);
Expand Down Expand Up @@ -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'
);
Expand Down
4 changes: 4 additions & 0 deletions plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4dfc927

Please sign in to comment.