Skip to content

Commit 11a366d

Browse files
committed
Address review comments
1 parent 64125c1 commit 11a366d

File tree

3 files changed

+197
-45
lines changed

3 files changed

+197
-45
lines changed

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

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ function createDbSpanMatcher(operationName: string, descriptionMatcher: unknown
1212
'db.system.name': 'postgres',
1313
'db.operation.name': operationName,
1414
'sentry.op': 'db',
15-
'sentry.origin': 'auto.db.otel.postgres',
15+
'sentry.origin': 'auto.db.postgresjs',
1616
'server.address': 'localhost',
1717
'server.port': 5444,
1818
}),
1919
description: descriptionMatcher,
2020
op: 'db',
21-
origin: 'auto.db.otel.postgres',
21+
origin: 'auto.db.postgresjs',
2222
});
2323
}
2424

@@ -39,15 +39,15 @@ describe('postgresjs auto instrumentation', () => {
3939
'db.query.text':
4040
'CREATE TABLE "User" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(?) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"))',
4141
'sentry.op': 'db',
42-
'sentry.origin': 'auto.db.otel.postgres',
42+
'sentry.origin': 'auto.db.postgresjs',
4343
'server.address': 'localhost',
4444
'server.port': 5444,
4545
}),
4646
description:
4747
'CREATE TABLE "User" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(?) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"))',
4848
op: 'db',
4949
status: 'ok',
50-
origin: 'auto.db.otel.postgres',
50+
origin: 'auto.db.postgresjs',
5151
parent_span_id: expect.any(String),
5252
span_id: expect.any(String),
5353
start_timestamp: expect.any(Number),
@@ -60,15 +60,15 @@ describe('postgresjs auto instrumentation', () => {
6060
'db.system.name': 'postgres',
6161
'db.operation.name': 'INSERT',
6262
'db.query.text': `INSERT INTO "User" ("email", "name") VALUES ('Foo', '${EXISTING_TEST_EMAIL}')`,
63-
'sentry.origin': 'auto.db.otel.postgres',
63+
'sentry.origin': 'auto.db.postgresjs',
6464
'sentry.op': 'db',
6565
'server.address': 'localhost',
6666
'server.port': 5444,
6767
}),
6868
description: `INSERT INTO "User" ("email", "name") VALUES ('Foo', '${EXISTING_TEST_EMAIL}')`,
6969
op: 'db',
7070
status: 'ok',
71-
origin: 'auto.db.otel.postgres',
71+
origin: 'auto.db.postgresjs',
7272
parent_span_id: expect.any(String),
7373
span_id: expect.any(String),
7474
start_timestamp: expect.any(Number),
@@ -82,14 +82,14 @@ describe('postgresjs auto instrumentation', () => {
8282
'db.operation.name': 'UPDATE',
8383
'db.query.text': `UPDATE "User" SET "name" = 'Foo' WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
8484
'sentry.op': 'db',
85-
'sentry.origin': 'auto.db.otel.postgres',
85+
'sentry.origin': 'auto.db.postgresjs',
8686
'server.address': 'localhost',
8787
'server.port': 5444,
8888
}),
8989
description: `UPDATE "User" SET "name" = 'Foo' WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
9090
op: 'db',
9191
status: 'ok',
92-
origin: 'auto.db.otel.postgres',
92+
origin: 'auto.db.postgresjs',
9393
parent_span_id: expect.any(String),
9494
span_id: expect.any(String),
9595
start_timestamp: expect.any(Number),
@@ -103,14 +103,14 @@ describe('postgresjs auto instrumentation', () => {
103103
'db.operation.name': 'SELECT',
104104
'db.query.text': `SELECT * FROM "User" WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
105105
'sentry.op': 'db',
106-
'sentry.origin': 'auto.db.otel.postgres',
106+
'sentry.origin': 'auto.db.postgresjs',
107107
'server.address': 'localhost',
108108
'server.port': 5444,
109109
}),
110110
description: `SELECT * FROM "User" WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
111111
op: 'db',
112112
status: 'ok',
113-
origin: 'auto.db.otel.postgres',
113+
origin: 'auto.db.postgresjs',
114114
parent_span_id: expect.any(String),
115115
span_id: expect.any(String),
116116
start_timestamp: expect.any(Number),
@@ -124,14 +124,14 @@ describe('postgresjs auto instrumentation', () => {
124124
'db.operation.name': 'SELECT',
125125
'db.query.text': 'SELECT * from generate_series(?,?) as x',
126126
'sentry.op': 'db',
127-
'sentry.origin': 'auto.db.otel.postgres',
127+
'sentry.origin': 'auto.db.postgresjs',
128128
'server.address': 'localhost',
129129
'server.port': 5444,
130130
}),
131131
description: 'SELECT * from generate_series(?,?) as x',
132132
op: 'db',
133133
status: 'ok',
134-
origin: 'auto.db.otel.postgres',
134+
origin: 'auto.db.postgresjs',
135135
parent_span_id: expect.any(String),
136136
span_id: expect.any(String),
137137
start_timestamp: expect.any(Number),
@@ -145,14 +145,14 @@ describe('postgresjs auto instrumentation', () => {
145145
'db.operation.name': 'DROP TABLE',
146146
'db.query.text': 'DROP TABLE "User"',
147147
'sentry.op': 'db',
148-
'sentry.origin': 'auto.db.otel.postgres',
148+
'sentry.origin': 'auto.db.postgresjs',
149149
'server.address': 'localhost',
150150
'server.port': 5444,
151151
}),
152152
description: 'DROP TABLE "User"',
153153
op: 'db',
154154
status: 'ok',
155-
origin: 'auto.db.otel.postgres',
155+
origin: 'auto.db.postgresjs',
156156
parent_span_id: expect.any(String),
157157
span_id: expect.any(String),
158158
start_timestamp: expect.any(Number),
@@ -168,14 +168,14 @@ describe('postgresjs auto instrumentation', () => {
168168
'error.type': 'PostgresError',
169169
'db.query.text': `SELECT * FROM "User" WHERE "email" = '${NON_EXISTING_TEST_EMAIL}'`,
170170
'sentry.op': 'db',
171-
'sentry.origin': 'auto.db.otel.postgres',
171+
'sentry.origin': 'auto.db.postgresjs',
172172
'server.address': 'localhost',
173173
'server.port': 5444,
174174
}),
175175
description: `SELECT * FROM "User" WHERE "email" = '${NON_EXISTING_TEST_EMAIL}'`,
176176
op: 'db',
177177
status: 'internal_error',
178-
origin: 'auto.db.otel.postgres',
178+
origin: 'auto.db.postgresjs',
179179
parent_span_id: expect.any(String),
180180
span_id: expect.any(String),
181181
start_timestamp: expect.any(Number),
@@ -234,15 +234,15 @@ describe('postgresjs auto instrumentation', () => {
234234
'db.query.text':
235235
'CREATE TABLE "User" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(?) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"))',
236236
'sentry.op': 'db',
237-
'sentry.origin': 'auto.db.otel.postgres',
237+
'sentry.origin': 'auto.db.postgresjs',
238238
'server.address': 'localhost',
239239
'server.port': 5444,
240240
}),
241241
description:
242242
'CREATE TABLE "User" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(?) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"))',
243243
op: 'db',
244244
status: 'ok',
245-
origin: 'auto.db.otel.postgres',
245+
origin: 'auto.db.postgresjs',
246246
parent_span_id: expect.any(String),
247247
span_id: expect.any(String),
248248
start_timestamp: expect.any(Number),
@@ -255,15 +255,15 @@ describe('postgresjs auto instrumentation', () => {
255255
'db.system.name': 'postgres',
256256
'db.operation.name': 'INSERT',
257257
'db.query.text': `INSERT INTO "User" ("email", "name") VALUES ('Foo', '${EXISTING_TEST_EMAIL}')`,
258-
'sentry.origin': 'auto.db.otel.postgres',
258+
'sentry.origin': 'auto.db.postgresjs',
259259
'sentry.op': 'db',
260260
'server.address': 'localhost',
261261
'server.port': 5444,
262262
}),
263263
description: `INSERT INTO "User" ("email", "name") VALUES ('Foo', '${EXISTING_TEST_EMAIL}')`,
264264
op: 'db',
265265
status: 'ok',
266-
origin: 'auto.db.otel.postgres',
266+
origin: 'auto.db.postgresjs',
267267
parent_span_id: expect.any(String),
268268
span_id: expect.any(String),
269269
start_timestamp: expect.any(Number),
@@ -277,14 +277,14 @@ describe('postgresjs auto instrumentation', () => {
277277
'db.operation.name': 'UPDATE',
278278
'db.query.text': `UPDATE "User" SET "name" = 'Foo' WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
279279
'sentry.op': 'db',
280-
'sentry.origin': 'auto.db.otel.postgres',
280+
'sentry.origin': 'auto.db.postgresjs',
281281
'server.address': 'localhost',
282282
'server.port': 5444,
283283
}),
284284
description: `UPDATE "User" SET "name" = 'Foo' WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
285285
op: 'db',
286286
status: 'ok',
287-
origin: 'auto.db.otel.postgres',
287+
origin: 'auto.db.postgresjs',
288288
parent_span_id: expect.any(String),
289289
span_id: expect.any(String),
290290
start_timestamp: expect.any(Number),
@@ -298,14 +298,14 @@ describe('postgresjs auto instrumentation', () => {
298298
'db.operation.name': 'SELECT',
299299
'db.query.text': `SELECT * FROM "User" WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
300300
'sentry.op': 'db',
301-
'sentry.origin': 'auto.db.otel.postgres',
301+
'sentry.origin': 'auto.db.postgresjs',
302302
'server.address': 'localhost',
303303
'server.port': 5444,
304304
}),
305305
description: `SELECT * FROM "User" WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
306306
op: 'db',
307307
status: 'ok',
308-
origin: 'auto.db.otel.postgres',
308+
origin: 'auto.db.postgresjs',
309309
parent_span_id: expect.any(String),
310310
span_id: expect.any(String),
311311
start_timestamp: expect.any(Number),
@@ -319,14 +319,14 @@ describe('postgresjs auto instrumentation', () => {
319319
'db.operation.name': 'SELECT',
320320
'db.query.text': 'SELECT * from generate_series(?,?) as x',
321321
'sentry.op': 'db',
322-
'sentry.origin': 'auto.db.otel.postgres',
322+
'sentry.origin': 'auto.db.postgresjs',
323323
'server.address': 'localhost',
324324
'server.port': 5444,
325325
}),
326326
description: 'SELECT * from generate_series(?,?) as x',
327327
op: 'db',
328328
status: 'ok',
329-
origin: 'auto.db.otel.postgres',
329+
origin: 'auto.db.postgresjs',
330330
parent_span_id: expect.any(String),
331331
span_id: expect.any(String),
332332
start_timestamp: expect.any(Number),
@@ -340,14 +340,14 @@ describe('postgresjs auto instrumentation', () => {
340340
'db.operation.name': 'DROP TABLE',
341341
'db.query.text': 'DROP TABLE "User"',
342342
'sentry.op': 'db',
343-
'sentry.origin': 'auto.db.otel.postgres',
343+
'sentry.origin': 'auto.db.postgresjs',
344344
'server.address': 'localhost',
345345
'server.port': 5444,
346346
}),
347347
description: 'DROP TABLE "User"',
348348
op: 'db',
349349
status: 'ok',
350-
origin: 'auto.db.otel.postgres',
350+
origin: 'auto.db.postgresjs',
351351
parent_span_id: expect.any(String),
352352
span_id: expect.any(String),
353353
start_timestamp: expect.any(Number),
@@ -363,14 +363,14 @@ describe('postgresjs auto instrumentation', () => {
363363
'error.type': 'PostgresError',
364364
'db.query.text': `SELECT * FROM "User" WHERE "email" = '${NON_EXISTING_TEST_EMAIL}'`,
365365
'sentry.op': 'db',
366-
'sentry.origin': 'auto.db.otel.postgres',
366+
'sentry.origin': 'auto.db.postgresjs',
367367
'server.address': 'localhost',
368368
'server.port': 5444,
369369
}),
370370
description: `SELECT * FROM "User" WHERE "email" = '${NON_EXISTING_TEST_EMAIL}'`,
371371
op: 'db',
372372
status: 'internal_error',
373-
origin: 'auto.db.otel.postgres',
373+
origin: 'auto.db.postgresjs',
374374
parent_span_id: expect.any(String),
375375
span_id: expect.any(String),
376376
start_timestamp: expect.any(Number),
@@ -431,15 +431,15 @@ describe('postgresjs auto instrumentation', () => {
431431
'CREATE TABLE "User" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(?) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"))',
432432
'custom.requestHook': 'called',
433433
'sentry.op': 'db',
434-
'sentry.origin': 'auto.db.otel.postgres',
434+
'sentry.origin': 'auto.db.postgresjs',
435435
'server.address': 'localhost',
436436
'server.port': 5444,
437437
}),
438438
description:
439439
'CREATE TABLE "User" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(?) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"))',
440440
op: 'db',
441441
status: 'ok',
442-
origin: 'auto.db.otel.postgres',
442+
origin: 'auto.db.postgresjs',
443443
}),
444444
expect.objectContaining({
445445
data: expect.objectContaining({
@@ -449,14 +449,14 @@ describe('postgresjs auto instrumentation', () => {
449449
'db.query.text': `INSERT INTO "User" ("email", "name") VALUES ('Foo', '${EXISTING_TEST_EMAIL}')`,
450450
'custom.requestHook': 'called',
451451
'sentry.op': 'db',
452-
'sentry.origin': 'auto.db.otel.postgres',
452+
'sentry.origin': 'auto.db.postgresjs',
453453
'server.address': 'localhost',
454454
'server.port': 5444,
455455
}),
456456
description: `INSERT INTO "User" ("email", "name") VALUES ('Foo', '${EXISTING_TEST_EMAIL}')`,
457457
op: 'db',
458458
status: 'ok',
459-
origin: 'auto.db.otel.postgres',
459+
origin: 'auto.db.postgresjs',
460460
}),
461461
expect.objectContaining({
462462
data: expect.objectContaining({
@@ -466,14 +466,14 @@ describe('postgresjs auto instrumentation', () => {
466466
'db.query.text': `SELECT * FROM "User" WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
467467
'custom.requestHook': 'called',
468468
'sentry.op': 'db',
469-
'sentry.origin': 'auto.db.otel.postgres',
469+
'sentry.origin': 'auto.db.postgresjs',
470470
'server.address': 'localhost',
471471
'server.port': 5444,
472472
}),
473473
description: `SELECT * FROM "User" WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
474474
op: 'db',
475475
status: 'ok',
476-
origin: 'auto.db.otel.postgres',
476+
origin: 'auto.db.postgresjs',
477477
}),
478478
]),
479479
extra: expect.objectContaining({
@@ -507,15 +507,15 @@ describe('postgresjs auto instrumentation', () => {
507507
'CREATE TABLE "User" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(?) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"))',
508508
'custom.requestHook': 'called',
509509
'sentry.op': 'db',
510-
'sentry.origin': 'auto.db.otel.postgres',
510+
'sentry.origin': 'auto.db.postgresjs',
511511
'server.address': 'localhost',
512512
'server.port': 5444,
513513
}),
514514
description:
515515
'CREATE TABLE "User" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(?) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"))',
516516
op: 'db',
517517
status: 'ok',
518-
origin: 'auto.db.otel.postgres',
518+
origin: 'auto.db.postgresjs',
519519
}),
520520
expect.objectContaining({
521521
data: expect.objectContaining({
@@ -525,14 +525,14 @@ describe('postgresjs auto instrumentation', () => {
525525
'db.query.text': `INSERT INTO "User" ("email", "name") VALUES ('Foo', '${EXISTING_TEST_EMAIL}')`,
526526
'custom.requestHook': 'called',
527527
'sentry.op': 'db',
528-
'sentry.origin': 'auto.db.otel.postgres',
528+
'sentry.origin': 'auto.db.postgresjs',
529529
'server.address': 'localhost',
530530
'server.port': 5444,
531531
}),
532532
description: `INSERT INTO "User" ("email", "name") VALUES ('Foo', '${EXISTING_TEST_EMAIL}')`,
533533
op: 'db',
534534
status: 'ok',
535-
origin: 'auto.db.otel.postgres',
535+
origin: 'auto.db.postgresjs',
536536
}),
537537
expect.objectContaining({
538538
data: expect.objectContaining({
@@ -542,14 +542,14 @@ describe('postgresjs auto instrumentation', () => {
542542
'db.query.text': `SELECT * FROM "User" WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
543543
'custom.requestHook': 'called',
544544
'sentry.op': 'db',
545-
'sentry.origin': 'auto.db.otel.postgres',
545+
'sentry.origin': 'auto.db.postgresjs',
546546
'server.address': 'localhost',
547547
'server.port': 5444,
548548
}),
549549
description: `SELECT * FROM "User" WHERE "email" = '${EXISTING_TEST_EMAIL}'`,
550550
op: 'db',
551551
status: 'ok',
552-
origin: 'auto.db.otel.postgres',
552+
origin: 'auto.db.postgresjs',
553553
}),
554554
]),
555555
extra: expect.objectContaining({

packages/node/src/integrations/tracing/postgresjs.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ export class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsIns
396396
op: 'db',
397397
},
398398
(span: Span) => {
399-
addOriginToSpan(span, 'auto.db.otel.postgres');
399+
addOriginToSpan(span, 'auto.db.postgresjs');
400400

401401
span.setAttributes({
402402
[ATTR_DB_SYSTEM_NAME]: 'postgres',
@@ -517,7 +517,6 @@ export class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsIns
517517
.replace(/\b\d+\b/g, '?') // Replace standalone numbers
518518
// Collapse IN and in clauses (eg. IN (?, ?, ?, ?) to IN (?))
519519
.replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/gi, 'IN (?)')
520-
.substring(0, 1024) // Truncate to 1024 characters AFTER sanitization
521520
);
522521
}
523522

@@ -567,7 +566,7 @@ export class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsIns
567566
op: 'db',
568567
},
569568
(span: Span) => {
570-
addOriginToSpan(span, 'auto.db.otel.postgres');
569+
addOriginToSpan(span, 'auto.db.postgresjs');
571570

572571
span.setAttributes({
573572
[ATTR_DB_SYSTEM_NAME]: 'postgres',

0 commit comments

Comments
 (0)