sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

feat(node): Add breadcrumbs for `child_process` and `worker_thread`

Open timfish opened this issue 1 year ago • 1 comments

I saw these were available in diagnostics_channel so this PR adds a default integration that includes breadcrumbs for both child process and worker thread start, stop and error.

timfish avatar Oct 07 '24 15:10 timfish

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.73 KB - -
@sentry/browser - with treeshaking flags 21.53 KB - -
@sentry/browser (incl. Tracing) 35.12 KB - -
@sentry/browser (incl. Tracing, Replay) 71.86 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.26 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 76.21 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 88.99 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 90.82 KB - -
@sentry/browser (incl. metrics) 27 KB - -
@sentry/browser (incl. Feedback) 39.87 KB - -
@sentry/browser (incl. sendFeedback) 27.38 KB - -
@sentry/browser (incl. FeedbackAsync) 32.17 KB - -
@sentry/react 25.49 KB - -
@sentry/react (incl. Tracing) 38.09 KB - -
@sentry/vue 26.91 KB - -
@sentry/vue (incl. Tracing) 37.02 KB - -
@sentry/svelte 22.87 KB - -
CDN Bundle 24.11 KB - -
CDN Bundle (incl. Tracing) 36.96 KB - -
CDN Bundle (incl. Tracing, Replay) 71.65 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 76.99 KB - -
CDN Bundle - uncompressed 70.7 KB - -
CDN Bundle (incl. Tracing) - uncompressed 109.73 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 222.24 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 235.46 KB - -
@sentry/nextjs (client) 38.06 KB - -
@sentry/sveltekit (client) 35.74 KB - -
@sentry/node 125.45 KB +0.24% +305 B 🔺
@sentry/node - without tracing 94.54 KB +0.3% +289 B 🔺
@sentry/aws-serverless 104.07 KB +0.25% +263 B 🔺

View base workflow run

github-actions[bot] avatar Oct 07 '24 15:10 github-actions[bot]

Sorry for letting this one slip a bit. I have a concern with the value behind the individual things we log. Right now it seems we do:

  • child/worker spawned
  • child/worker exited

If I put myself into the seat of a user that looks at an error in Sentry, I don't think I care to much when a worker/child is created. I mostly care about whether I receive some faulty messages from a worker (I don't think we can instrument this reliably), or whether a child/worker dies unexpectedly.

What do you think about limiting the created breadcrumbs to error exits of children only?

lforst avatar Oct 22 '24 11:10 lforst

I mostly care about whether I receive some faulty messages from a worker (I don't think we can instrument this reliably)

Both Worker and ChildProcess are EventEmitters, so we could use the 'newListener' event to wrap users 'message' handlers and add things like tracing or to add some more context if their handler functions throw.

What do you think about limiting the created breadcrumbs to error exits of children only?

Yep makes sense, I'll change this!

timfish avatar Oct 22 '24 15:10 timfish

I mostly care about whether I receive some faulty messages from a worker (I don't think we can instrument this reliably)

Both Worker and ChildProcess are EventEmitters, so we could use the 'newListener' event to wrap users 'message' handlers and add things like tracing or to add some more context if their handler functions throw.

Ah that's good to know. I still have concerns with how spammy this potentially gets so let's keep this in our head in case we want to instrument it in the future. Or maybe we can make it optional 🤔

lforst avatar Oct 22 '24 15:10 lforst

Or maybe we can make it optional

We can also just add it later in another PR!

I guess we already do something similar in browserApiErrorsIntegration to wrap setTimeout, setInterval, etc? Why is that browser only and not needed in Node?

timfish avatar Oct 22 '24 15:10 timfish