Skip to content

Commit 36f605d

Browse files
committed
fix(pg-instrumentation): capture query props when passed as class instance
1 parent 73c7edc commit 36f605d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

packages/instrumentation-pg/src/instrumentation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConf
341341
: firstArgIsQueryObjectWithText
342342
? {
343343
...(arg0 as any),
344+
name: arg0.name,
345+
text: arg0.text,
344346
values:
345347
(arg0 as any).values ??
346348
(Array.isArray(args[1]) ? args[1] : undefined),

packages/instrumentation-pg/test/pg.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,10 +583,15 @@ describe('pg', () => {
583583
});
584584

585585
it('should record query and values for prepared statements', done => {
586-
const queryConfig = {
587-
name: 'get_pg_tables',
588-
text: 'SELECT * FROM pg_tables WHERE schemaname = $1',
589-
};
586+
class Statement {
587+
get name() {
588+
return 'get_pg_tables';
589+
}
590+
get text() {
591+
return 'SELECT * FROM pg_tables WHERE schemaname = $1';
592+
}
593+
}
594+
const queryConfig = new Statement();
590595
const values = ['public'];
591596

592597
const expectedAttributes = {

0 commit comments

Comments
 (0)