Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node): Bump opentelemetry/instrumentation-pg to 0.51.0 #15206

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,10 @@ jobs:
with:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}

- name: Build `libpq`
run: yarn libpq:build
working-directory: dev-packages/node-integration-tests

- name: Overwrite typescript version
if: matrix.typescript == '3.8'
run: node ./scripts/use-ts-3_8.js
Expand Down
4 changes: 3 additions & 1 deletion dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"clean:script": "node scripts/clean.js",
"prisma-v5:init": "cd suites/tracing/prisma-orm-v5 && yarn && yarn setup",
"prisma-v6:init": "cd suites/tracing/prisma-orm-v6 && yarn && yarn setup",
"libpq:build": "npm rebuild libpq",
"lint": "eslint . --format stylish",
"fix": "eslint . --format stylish --fix",
"type-check": "tsc",
Expand Down Expand Up @@ -62,7 +63,8 @@
"nock": "^13.5.5",
"node-cron": "^3.0.3",
"node-schedule": "^2.1.1",
"pg": "^8.7.3",
"pg": "^8.13.1",
"pg-native": "3.2.0",
"proxy": "^2.1.1",
"redis-4": "npm:redis@^4.6.14",
"reflect-metadata": "0.2.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node');

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
tracesSampleRate: 1.0,
transport: loggingTransport,
});

// Stop the process from exiting before the transaction is sent
setInterval(() => {}, 1000);

const { native } = require('pg');
const { Client } = native;

const client = new Client({ port: 5444, user: 'test', password: 'test', database: 'tests' });

async function run() {
await Sentry.startSpan(
{
name: 'Test Transaction',
op: 'transaction',
},
async () => {
try {
await client.connect();

await client
.query(
'CREATE TABLE "NativeUser" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"));',
)
.catch(() => {
// if this is not a fresh database, the table might already exist
});

await client.query('INSERT INTO "NativeUser" ("email", "name") VALUES ($1, $2)', ['tim', '[email protected]']);
await client.query('SELECT * FROM "NativeUser"');
} finally {
await client.end();
}
},
);
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
run();
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,54 @@ describe('postgres auto instrumentation', () => {
.expect({ transaction: EXPECTED_TRANSACTION })
.start(done);
});

test('should auto-instrument `pg-native` package', done => {
const EXPECTED_TRANSACTION = {
transaction: 'Test Transaction',
spans: expect.arrayContaining([
expect.objectContaining({
data: expect.objectContaining({
'db.system': 'postgresql',
'db.name': 'tests',
'sentry.origin': 'manual',
'sentry.op': 'db',
}),
description: 'pg.connect',
op: 'db',
status: 'ok',
}),
expect.objectContaining({
data: expect.objectContaining({
'db.system': 'postgresql',
'db.name': 'tests',
'db.statement': 'INSERT INTO "NativeUser" ("email", "name") VALUES ($1, $2)',
'sentry.origin': 'auto.db.otel.postgres',
'sentry.op': 'db',
}),
description: 'INSERT INTO "NativeUser" ("email", "name") VALUES ($1, $2)',
op: 'db',
status: 'ok',
origin: 'auto.db.otel.postgres',
}),
expect.objectContaining({
data: expect.objectContaining({
'db.system': 'postgresql',
'db.name': 'tests',
'db.statement': 'SELECT * FROM "NativeUser"',
'sentry.origin': 'auto.db.otel.postgres',
'sentry.op': 'db',
}),
description: 'SELECT * FROM "NativeUser"',
op: 'db',
status: 'ok',
origin: 'auto.db.otel.postgres',
}),
]),
};

createRunner(__dirname, 'scenario-native.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start(done);
});
});
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@opentelemetry/instrumentation-mongoose": "0.46.0",
"@opentelemetry/instrumentation-mysql": "0.45.0",
"@opentelemetry/instrumentation-mysql2": "0.45.0",
"@opentelemetry/instrumentation-pg": "0.50.0",
"@opentelemetry/instrumentation-pg": "0.51.0",
"@opentelemetry/instrumentation-redis-4": "0.46.0",
"@opentelemetry/instrumentation-tedious": "0.18.0",
"@opentelemetry/instrumentation-undici": "0.10.0",
Expand Down
Loading
Loading