Skip to content

Commit 3ba19f8

Browse files
committed
Update tests
1 parent deb6a9e commit 3ba19f8

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

dev-packages/node-integration-tests/suites/tracing/postgresjs/scenario.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ async function run() {
4747
DROP TABLE "User";
4848
`;
4949

50+
// This will be captured as an error as the table no longer exists
5051
await sql`
51-
SELECT * FROM "User" WHERE "email" = 'bar@baz.com';
52+
SELECT * FROM "User" WHERE "email" = 'foo@baz.com';
5253
`;
5354
} finally {
5455
await sql.end();

dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,18 @@ describe('postgresjs auto instrumentation', () => {
158158
expect.objectContaining({
159159
data: expect.objectContaining({
160160
'db.namespace': 'test_db',
161-
'db.query.text': 'SELECT * FROM "User" WHERE "email" = \'bar@baz.com\'',
161+
'db.query.text': 'SELECT * FROM "User" WHERE "email" = \'foo@baz.com\'',
162162
'db.system.name': 'postgres',
163163
'sentry.op': 'db',
164164
'sentry.origin': 'manual',
165165
'server.address': 'localhost',
166166
'server.port': 5444,
167167
}),
168-
description: 'SELECT db:test_db',
168+
// This span is an error span and the `command` is not available when a does not resolve
169+
// That's why we can't update the span description when the query fails
170+
description: 'postgresjs.query',
169171
op: 'db',
170-
status: 'ok',
172+
status: 'unknown_error',
171173
origin: 'manual',
172174
parent_span_id: expect.any(String),
173175
span_id: expect.any(String),
@@ -184,14 +186,33 @@ describe('postgresjs auto instrumentation', () => {
184186
trace: {
185187
trace_id: expect.any(String),
186188
span_id: expect.any(String),
187-
status: 'unknown_error',
188189
},
189190
},
191+
exception: {
192+
values: [
193+
{
194+
type: 'PostgresError',
195+
value: 'relation "User" does not exist',
196+
stacktrace: expect.objectContaining({
197+
frames: expect.arrayContaining([
198+
expect.objectContaining({
199+
function: 'handle',
200+
module: 'postgres.cjs.src:connection',
201+
filename: expect.any(String),
202+
lineno: expect.any(Number),
203+
colno: expect.any(Number),
204+
}),
205+
]),
206+
}),
207+
},
208+
],
209+
},
190210
};
191211

192212
await createRunner(__dirname, 'scenario.js')
193213
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
194-
.expect({ transaction: EXPECTED_TRANSACTION, event: EXPECTED_ERROR_EVENT })
214+
.expect({ transaction: EXPECTED_TRANSACTION })
215+
.expect({ event: EXPECTED_ERROR_EVENT })
195216
.start()
196217
.completed();
197218
});

0 commit comments

Comments
 (0)