File tree Expand file tree Collapse file tree 13 files changed +748
-3
lines changed
e2e-tests/test-applications/node-exports-test-app/scripts
node-integration-tests/suites
breadcrumbs/process-thread
google-cloud-serverless/src Expand file tree Collapse file tree 13 files changed +748
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ const DEPENDENTS: Dependent[] = [
5050 ignoreExports : [
5151 // not supported in bun:
5252 'NodeClient' ,
53+ // Bun doesn't emit the required diagnostics_channel events
54+ 'processThreadBreadcrumbIntegration' ,
5355 ] ,
5456 } ,
5557 {
Original file line number Diff line number Diff line change @@ -56,12 +56,12 @@ const ANR_EVENT_WITH_SCOPE = {
5656 user : {
5757 email : 'person@home.com' ,
5858 } ,
59- breadcrumbs : [
59+ breadcrumbs : expect . arrayContaining ( [
6060 {
6161 timestamp : expect . any ( Number ) ,
6262 message : 'important message!' ,
6363 } ,
64- ] ,
64+ ] ) ,
6565} ;
6666
6767conditionalTest ( { min : 16 } ) ( 'should report ANR when event loop blocked' , ( ) => {
Original file line number Diff line number Diff line change 1+ import { spawn } from 'child_process' ;
2+ import { join } from 'path' ;
3+ import { loggingTransport } from '@sentry-internal/node-integration-tests' ;
4+ import * as Sentry from '@sentry/node' ;
5+ import { Worker } from 'worker_threads' ;
6+
7+ const __dirname = new URL ( '.' , import . meta. url ) . pathname ;
8+
9+ Sentry . init ( {
10+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
11+ release : '1.0' ,
12+ transport : loggingTransport ,
13+ } ) ;
14+
15+ await new Promise ( resolve => {
16+ const child = spawn ( 'sleep' , [ 'a' ] ) ;
17+ child . on ( 'error' , resolve ) ;
18+ child . on ( 'exit' , resolve ) ;
19+ } ) ;
20+
21+ await new Promise ( resolve => {
22+ const worker = new Worker ( join ( __dirname , 'worker.mjs' ) ) ;
23+ worker . on ( 'error' , resolve ) ;
24+ worker . on ( 'exit' , resolve ) ;
25+ } ) ;
26+
27+ throw new Error ( 'This is a test error' ) ;
Original file line number Diff line number Diff line change 1+ import type { Event } from '@sentry/types' ;
2+ import { conditionalTest } from '../../../utils' ;
3+ import { cleanupChildProcesses , createRunner } from '../../../utils/runner' ;
4+
5+ const EVENT = {
6+ // and an exception that is our ANR
7+ exception : {
8+ values : [
9+ {
10+ type : 'Error' ,
11+ value : 'This is a test error' ,
12+ } ,
13+ ] ,
14+ } ,
15+ breadcrumbs : [
16+ {
17+ timestamp : expect . any ( Number ) ,
18+ category : 'child_process' ,
19+ message : "Child process exited with code '1'" ,
20+ level : 'warning' ,
21+ data : {
22+ spawnfile : 'sleep' ,
23+ } ,
24+ } ,
25+ {
26+ timestamp : expect . any ( Number ) ,
27+ category : 'worker_thread' ,
28+ message : "Worker thread errored with 'Worker error'" ,
29+ level : 'error' ,
30+ data : {
31+ threadId : expect . any ( Number ) ,
32+ } ,
33+ } ,
34+ ] ,
35+ } ;
36+
37+ conditionalTest ( { min : 20 } ) ( 'should capture process and thread breadcrumbs' , ( ) => {
38+ afterAll ( ( ) => {
39+ cleanupChildProcesses ( ) ;
40+ } ) ;
41+
42+ test ( 'ESM' , done => {
43+ createRunner ( __dirname , 'app.mjs' )
44+ . withMockSentryServer ( )
45+ . expect ( { event : EVENT as Event } )
46+ . start ( done ) ;
47+ } ) ;
48+ } ) ;
Original file line number Diff line number Diff line change 1+ throw new Error ( 'Worker error' ) ;
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ export {
8989 parameterize ,
9090 postgresIntegration ,
9191 prismaIntegration ,
92+ processThreadBreadcrumbIntegration ,
9293 redisIntegration ,
9394 requestDataIntegration ,
9495 rewriteFramesIntegration ,
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ export {
102102 setupNestErrorHandler ,
103103 postgresIntegration ,
104104 prismaIntegration ,
105+ processThreadBreadcrumbIntegration ,
105106 hapiIntegration ,
106107 setupHapiErrorHandler ,
107108 spotlightIntegration ,
Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ export {
114114 zodErrorsIntegration ,
115115 profiler ,
116116 amqplibIntegration ,
117+ processThreadBreadcrumbIntegration ,
117118} from '@sentry/node' ;
118119
119120export {
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ export { spotlightIntegration } from './integrations/spotlight';
3131export { genericPoolIntegration } from './integrations/tracing/genericPool' ;
3232export { dataloaderIntegration } from './integrations/tracing/dataloader' ;
3333export { amqplibIntegration } from './integrations/tracing/amqplib' ;
34+ export { processThreadBreadcrumbIntegration } from './integrations/processThread' ;
3435
3536export { SentryContextManager } from './otel/contextManager' ;
3637export { generateInstrumentOnce } from './otel/instrument' ;
You can’t perform that action at this time.
0 commit comments