From 172ba68638546311cb4520dec38d7662a52512f2 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 18 Nov 2024 09:06:56 +0000 Subject: [PATCH 1/4] feat(node): Add alias `childProcessIntegration` for `processThreadBreadcrumbIntegration` and deprecate it --- .../scripts/consistentExports.ts | 1 + docs/migration/draft-v9-migration-guide.md | 6 +++++- packages/astro/src/index.server.ts | 1 + packages/aws-serverless/src/index.ts | 1 + packages/google-cloud-serverless/src/index.ts | 1 + packages/node/src/index.ts | 3 ++- packages/node/src/integrations/processThread.ts | 12 ++++++++---- packages/node/src/sdk/index.ts | 4 ++-- 8 files changed, 21 insertions(+), 8 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts b/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts index 546639e8a766..83f9c1639cdc 100644 --- a/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts +++ b/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts @@ -52,6 +52,7 @@ const DEPENDENTS: Dependent[] = [ 'NodeClient', // Bun doesn't emit the required diagnostics_channel events 'processThreadBreadcrumbIntegration', + 'childProcessIntegration', ], }, { diff --git a/docs/migration/draft-v9-migration-guide.md b/docs/migration/draft-v9-migration-guide.md index bbbb2c2d367f..8b0cebd7e51d 100644 --- a/docs/migration/draft-v9-migration-guide.md +++ b/docs/migration/draft-v9-migration-guide.md @@ -12,6 +12,10 @@ - Deprecated `transactionNamingScheme` option in `requestDataIntegration`. -## `@sentry/types`` +## `@sentry/types` - Deprecated `Request` in favor of `RequestEventData`. + +## Server-side SDKs (`@sentry/node` and all dependents) + +- Deprecated `processThreadBreadcrumbIntegration` in favor of `childProcessIntegration`. Functionally they are the same. diff --git a/packages/astro/src/index.server.ts b/packages/astro/src/index.server.ts index e4c871ec74ea..1d3026305efc 100644 --- a/packages/astro/src/index.server.ts +++ b/packages/astro/src/index.server.ts @@ -92,6 +92,7 @@ export { postgresIntegration, prismaIntegration, processThreadBreadcrumbIntegration, + childProcessIntegration, redisIntegration, requestDataIntegration, rewriteFramesIntegration, diff --git a/packages/aws-serverless/src/index.ts b/packages/aws-serverless/src/index.ts index 060dddd51787..b3f47db2cbfd 100644 --- a/packages/aws-serverless/src/index.ts +++ b/packages/aws-serverless/src/index.ts @@ -106,6 +106,7 @@ export { postgresIntegration, prismaIntegration, processThreadBreadcrumbIntegration, + childProcessIntegration, hapiIntegration, setupHapiErrorHandler, spotlightIntegration, diff --git a/packages/google-cloud-serverless/src/index.ts b/packages/google-cloud-serverless/src/index.ts index 5e1c2bba5bc1..31393dc5f63f 100644 --- a/packages/google-cloud-serverless/src/index.ts +++ b/packages/google-cloud-serverless/src/index.ts @@ -118,6 +118,7 @@ export { profiler, amqplibIntegration, processThreadBreadcrumbIntegration, + childProcessIntegration, } from '@sentry/node'; export { diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 88b105682e6d..c609aaa0c59b 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -33,7 +33,8 @@ export { tediousIntegration } from './integrations/tracing/tedious'; export { genericPoolIntegration } from './integrations/tracing/genericPool'; export { dataloaderIntegration } from './integrations/tracing/dataloader'; export { amqplibIntegration } from './integrations/tracing/amqplib'; -export { processThreadBreadcrumbIntegration } from './integrations/processThread'; +// eslint-disable-next-line deprecation/deprecation +export { processThreadBreadcrumbIntegration, childProcessIntegration } from './integrations/processThread'; export { SentryContextManager } from './otel/contextManager'; export { generateInstrumentOnce } from './otel/instrument'; diff --git a/packages/node/src/integrations/processThread.ts b/packages/node/src/integrations/processThread.ts index 870a0dc6df64..53ca9d829850 100644 --- a/packages/node/src/integrations/processThread.ts +++ b/packages/node/src/integrations/processThread.ts @@ -2,7 +2,6 @@ import type { ChildProcess } from 'node:child_process'; import * as diagnosticsChannel from 'node:diagnostics_channel'; import type { Worker } from 'node:worker_threads'; import { addBreadcrumb, defineIntegration } from '@sentry/core'; -import type { IntegrationFn } from '@sentry/types'; interface Options { /** @@ -15,7 +14,10 @@ interface Options { const INTEGRATION_NAME = 'ProcessAndThreadBreadcrumbs'; -const _processThreadBreadcrumbIntegration = ((options: Options = {}) => { +/** + * Capture breadcrumbs for child processes and worker threads. + */ +export const childProcessIntegration = defineIntegration((options: Options = {}) => { return { name: INTEGRATION_NAME, setup(_client) { @@ -34,12 +36,14 @@ const _processThreadBreadcrumbIntegration = ((options: Options = {}) => { }); }, }; -}) satisfies IntegrationFn; +}); /** * Capture breadcrumbs for child processes and worker threads. + * + * @deprecated Use `childProcessIntegration` integration instead. Functionally they are the same. `processThreadBreadcrumbIntegration` will be removed in the next major version. */ -export const processThreadBreadcrumbIntegration = defineIntegration(_processThreadBreadcrumbIntegration); +export const processThreadBreadcrumbIntegration = childProcessIntegration; function captureChildProcessEvents(child: ChildProcess, options: Options): void { let hasExited = false; diff --git a/packages/node/src/sdk/index.ts b/packages/node/src/sdk/index.ts index 87d61cc908bc..948349dd9189 100644 --- a/packages/node/src/sdk/index.ts +++ b/packages/node/src/sdk/index.ts @@ -36,7 +36,7 @@ import { modulesIntegration } from '../integrations/modules'; import { nativeNodeFetchIntegration } from '../integrations/node-fetch'; import { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception'; import { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection'; -import { processThreadBreadcrumbIntegration } from '../integrations/processThread'; +import { childProcessIntegration } from '../integrations/processThread'; import { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight'; import { getAutoPerformanceIntegrations } from '../integrations/tracing'; import { makeNodeTransport } from '../transports'; @@ -72,7 +72,7 @@ export function getDefaultIntegrationsWithoutPerformance(): Integration[] { contextLinesIntegration(), localVariablesIntegration(), nodeContextIntegration(), - processThreadBreadcrumbIntegration(), + childProcessIntegration(), ...getCjsOnlyIntegrations(), ]; } From 640f1e812873d912affce9b20fe0115ea4a5afed Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 18 Nov 2024 10:24:22 +0000 Subject: [PATCH 2/4] lint --- packages/aws-serverless/src/index.ts | 1 + packages/google-cloud-serverless/src/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/aws-serverless/src/index.ts b/packages/aws-serverless/src/index.ts index b3f47db2cbfd..8341b01719c1 100644 --- a/packages/aws-serverless/src/index.ts +++ b/packages/aws-serverless/src/index.ts @@ -105,6 +105,7 @@ export { setupNestErrorHandler, postgresIntegration, prismaIntegration, + // eslint-disable-next-line deprecation/deprecation processThreadBreadcrumbIntegration, childProcessIntegration, hapiIntegration, diff --git a/packages/google-cloud-serverless/src/index.ts b/packages/google-cloud-serverless/src/index.ts index 31393dc5f63f..53cf4c026868 100644 --- a/packages/google-cloud-serverless/src/index.ts +++ b/packages/google-cloud-serverless/src/index.ts @@ -117,6 +117,7 @@ export { zodErrorsIntegration, profiler, amqplibIntegration, + // eslint-disable-next-line deprecation/deprecation processThreadBreadcrumbIntegration, childProcessIntegration, } from '@sentry/node'; From 0700a3cb60c70455d28c9463631bdec4bdda1e06 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 18 Nov 2024 10:48:23 +0000 Subject: [PATCH 3/4] lint some more --- packages/astro/src/index.server.ts | 1 + packages/node/src/index.ts | 2 +- .../node/src/integrations/{processThread.ts => childProcess.ts} | 1 + packages/node/src/sdk/index.ts | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) rename packages/node/src/integrations/{processThread.ts => childProcess.ts} (98%) diff --git a/packages/astro/src/index.server.ts b/packages/astro/src/index.server.ts index 1d3026305efc..853623abbc8a 100644 --- a/packages/astro/src/index.server.ts +++ b/packages/astro/src/index.server.ts @@ -91,6 +91,7 @@ export { parameterize, postgresIntegration, prismaIntegration, + // eslint-disable-next-line deprecation/deprecation processThreadBreadcrumbIntegration, childProcessIntegration, redisIntegration, diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index c609aaa0c59b..cc81dce37577 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -34,7 +34,7 @@ export { genericPoolIntegration } from './integrations/tracing/genericPool'; export { dataloaderIntegration } from './integrations/tracing/dataloader'; export { amqplibIntegration } from './integrations/tracing/amqplib'; // eslint-disable-next-line deprecation/deprecation -export { processThreadBreadcrumbIntegration, childProcessIntegration } from './integrations/processThread'; +export { processThreadBreadcrumbIntegration, childProcessIntegration } from './integrations/childProcess'; export { SentryContextManager } from './otel/contextManager'; export { generateInstrumentOnce } from './otel/instrument'; diff --git a/packages/node/src/integrations/processThread.ts b/packages/node/src/integrations/childProcess.ts similarity index 98% rename from packages/node/src/integrations/processThread.ts rename to packages/node/src/integrations/childProcess.ts index 53ca9d829850..99525b4092b4 100644 --- a/packages/node/src/integrations/processThread.ts +++ b/packages/node/src/integrations/childProcess.ts @@ -12,6 +12,7 @@ interface Options { includeChildProcessArgs?: boolean; } +// TODO(v9): Update this name and mention in migration docs. const INTEGRATION_NAME = 'ProcessAndThreadBreadcrumbs'; /** diff --git a/packages/node/src/sdk/index.ts b/packages/node/src/sdk/index.ts index 948349dd9189..710080217183 100644 --- a/packages/node/src/sdk/index.ts +++ b/packages/node/src/sdk/index.ts @@ -36,7 +36,7 @@ import { modulesIntegration } from '../integrations/modules'; import { nativeNodeFetchIntegration } from '../integrations/node-fetch'; import { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception'; import { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection'; -import { childProcessIntegration } from '../integrations/processThread'; +import { childProcessIntegration } from '../integrations/childProcess'; import { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight'; import { getAutoPerformanceIntegrations } from '../integrations/tracing'; import { makeNodeTransport } from '../transports'; From 1adc0023df81548145e519bf4963dd1c90b44e52 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 18 Nov 2024 12:54:43 +0000 Subject: [PATCH 4/4] lint --- packages/node/src/sdk/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node/src/sdk/index.ts b/packages/node/src/sdk/index.ts index 710080217183..edebeea384db 100644 --- a/packages/node/src/sdk/index.ts +++ b/packages/node/src/sdk/index.ts @@ -30,13 +30,13 @@ import { consoleIntegration } from '../integrations/console'; import { nodeContextIntegration } from '../integrations/context'; import { contextLinesIntegration } from '../integrations/contextlines'; +import { childProcessIntegration } from '../integrations/childProcess'; import { httpIntegration } from '../integrations/http'; import { localVariablesIntegration } from '../integrations/local-variables'; import { modulesIntegration } from '../integrations/modules'; import { nativeNodeFetchIntegration } from '../integrations/node-fetch'; import { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception'; import { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection'; -import { childProcessIntegration } from '../integrations/childProcess'; import { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight'; import { getAutoPerformanceIntegrations } from '../integrations/tracing'; import { makeNodeTransport } from '../transports';