@@ -295,4 +295,79 @@ conditionalTest({ min: 20 })('Pino integration', () => {
295295 . start ( )
296296 . completed ( ) ;
297297 } ) ;
298+
299+ test ( 'captures logs with custom messageKey and errorKey' , async ( ) => {
300+ const instrumentPath = join ( __dirname , 'instrument.mjs' ) ;
301+
302+ await createRunner ( __dirname , 'scenario-custom-keys.mjs' )
303+ . withMockSentryServer ( )
304+ . withInstrument ( instrumentPath )
305+ . ignore ( 'transaction' )
306+ . expect ( {
307+ event : {
308+ exception : {
309+ values : [
310+ {
311+ type : 'Error' ,
312+ value : 'Custom error key' ,
313+ mechanism : {
314+ type : 'pino' ,
315+ handled : true ,
316+ } ,
317+ stacktrace : {
318+ frames : expect . arrayContaining ( [
319+ expect . objectContaining ( {
320+ function : '?' ,
321+ in_app : true ,
322+ module : 'scenario-custom-keys' ,
323+ } ) ,
324+ ] ) ,
325+ } ,
326+ } ,
327+ ] ,
328+ } ,
329+ } ,
330+ } )
331+ . expect ( {
332+ log : {
333+ items : [
334+ {
335+ timestamp : expect . any ( Number ) ,
336+ level : 'info' ,
337+ body : 'Custom message key' ,
338+ trace_id : expect . any ( String ) ,
339+ severity_number : 9 ,
340+ attributes : {
341+ name : { value : 'myapp' , type : 'string' } ,
342+ 'pino.logger.level' : { value : 30 , type : 'integer' } ,
343+ user : { value : 'user-123' , type : 'string' } ,
344+ action : { value : 'custom-key-test' , type : 'string' } ,
345+ message : { value : 'Custom message key' , type : 'string' } ,
346+ 'sentry.origin' : { value : 'auto.log.pino' , type : 'string' } ,
347+ 'sentry.release' : { value : '1.0' , type : 'string' } ,
348+ 'sentry.sdk.name' : { value : 'sentry.javascript.node' , type : 'string' } ,
349+ } ,
350+ } ,
351+ {
352+ timestamp : expect . any ( Number ) ,
353+ level : 'error' ,
354+ body : 'Custom error key' ,
355+ trace_id : expect . any ( String ) ,
356+ severity_number : 17 ,
357+ attributes : {
358+ name : { value : 'myapp' , type : 'string' } ,
359+ 'pino.logger.level' : { value : 50 , type : 'integer' } ,
360+ message : { value : 'Custom error key' , type : 'string' } ,
361+ error : { value : expect . any ( String ) , type : 'string' } ,
362+ 'sentry.origin' : { value : 'auto.log.pino' , type : 'string' } ,
363+ 'sentry.release' : { value : '1.0' , type : 'string' } ,
364+ 'sentry.sdk.name' : { value : 'sentry.javascript.node' , type : 'string' } ,
365+ } ,
366+ } ,
367+ ] ,
368+ } ,
369+ } )
370+ . start ( )
371+ . completed ( ) ;
372+ } ) ;
298373} ) ;
0 commit comments