Skip to content
Open
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
33 changes: 15 additions & 18 deletions packages/instrumentation-pg/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,24 +333,21 @@ export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConf
// TODO: remove the `as ...` casts below when the TS version is upgraded.
// Newer TS versions will use the result of firstArgIsQueryObjectWithText
// to properly narrow arg0, but TS 4.3.5 does not.
let queryConfig: any;

if (firstArgIsString) {
queryConfig = {
text: arg0 as string,
values: Array.isArray(args[1]) ? args[1] : undefined,
};
} else if (firstArgIsQueryObjectWithText) {
const q = arg0 as any;

if (q.values === undefined && Array.isArray(args[1])) {
q.values = args[1];
}

queryConfig = q;
} else {
queryConfig = undefined;
}
const queryConfig = firstArgIsString
? {
text: arg0 as string,
values: Array.isArray(args[1]) ? args[1] : undefined,
}
: firstArgIsQueryObjectWithText
? {
...(arg0 as any),
name: arg0.name,
text: arg0.text,
values:
(arg0 as any).values ??
(Array.isArray(args[1]) ? args[1] : undefined),
}
: undefined;

const attributes: Attributes = {
[ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_POSTGRESQL,
Expand Down