-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(node)!: split childProcess integration into childProcess and worker integrations #22886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import type { Worker } from 'node:worker_threads'; | ||
| import * as diagnosticsChannel from 'node:diagnostics_channel'; | ||
| import { captureException, defineIntegration, isObjectLike } from '@sentry/core'; | ||
|
|
||
| const INTEGRATION_NAME = 'WorkerThreads' as const; | ||
|
|
||
| /** | ||
| * Capture events and errors of worker threads. | ||
| * For child process events, use `childProcessIntegration()` instead. | ||
| */ | ||
| export const workerThreadsIntegration = defineIntegration(() => { | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| return { | ||
| name: INTEGRATION_NAME, | ||
| setup() { | ||
| diagnosticsChannel.channel('worker_threads').subscribe((event: unknown) => { | ||
| if (isObjectLike(event) && 'worker' in event) { | ||
| captureWorkerThreadEvents(event.worker as Worker); | ||
| } | ||
| }); | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| function captureWorkerThreadEvents(worker: Worker): void { | ||
| let threadId: number | undefined; | ||
|
|
||
| worker | ||
| .on('online', () => { | ||
| threadId = worker.threadId; | ||
| }) | ||
| .on('error', error => { | ||
| captureException(error, { | ||
| mechanism: { | ||
|
sentry[bot] marked this conversation as resolved.
|
||
| type: 'auto.node.worker_threads', | ||
| handled: false, | ||
| data: threadId !== undefined ? { threadId: String(threadId) } : undefined, | ||
| }, | ||
| }); | ||
| }); | ||
|
Comment on lines
+29
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The Suggested FixThe Prompt for AI Agent |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.