File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
dev-packages/node-integration-tests/suites/tracing/postgresjs
packages/node/src/integrations/tracing Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const EXISTING_TEST_EMAIL = 'bar@baz.com';
55const NON_EXISTING_TEST_EMAIL = 'foo@baz.com' ;
66
77// Helper function to create basic span matcher (reduces duplication in new tests)
8- function createDbSpanMatcher ( operationName : string , descriptionMatcher : any = expect . any ( String ) ) {
8+ function createDbSpanMatcher ( operationName : string , descriptionMatcher : unknown = expect . any ( String ) ) {
99 return expect . objectContaining ( {
1010 data : expect . objectContaining ( {
1111 'db.namespace' : 'test_db' ,
Original file line number Diff line number Diff line change @@ -360,11 +360,14 @@ export class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsIns
360360
361361 const sanitizedSqlQuery = self . _sanitizeSqlQuery ( query . strings ?. [ 0 ] ) ;
362362
363- let spanName = sanitizedSqlQuery ?. trim ( ) || '' ;
364- if ( ! spanName ) {
365- // Fallback: try to extract operation from the sanitized query
366- const operationMatch = sanitizedSqlQuery ?. match ( SQL_OPERATION_REGEX ) ;
367- spanName = operationMatch ?. [ 1 ] ? `db.${ operationMatch [ 1 ] . toLowerCase ( ) } ` : 'db.query' ;
363+ let spanName : string ;
364+ const operationMatch = sanitizedSqlQuery ?. match ( SQL_OPERATION_REGEX ) ;
365+ if ( operationMatch ?. [ 1 ] ) {
366+ spanName = `db.${ operationMatch [ 1 ] . toLowerCase ( ) } ` ;
367+ } else if ( sanitizedSqlQuery ?. trim ( ) ) {
368+ spanName = sanitizedSqlQuery . trim ( ) ;
369+ } else {
370+ spanName = 'db.query' ;
368371 }
369372
370373 return startSpanManual (
You can’t perform that action at this time.
0 commit comments