@@ -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