@sentry/node 11.0.0-alpha.1 → 11.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/build/cjs/bundler-plugin/esbuild.js.map +1 -1
- package/build/cjs/bundler-plugin/rollup.js.map +1 -1
- package/build/cjs/bundler-plugin/vite.js.map +1 -1
- package/build/cjs/bundler-plugin/webpack.js.map +1 -1
- package/build/cjs/index.js +56 -56
- package/build/cjs/integrations/anr/index.js +1 -1
- package/build/cjs/integrations/childProcess.js +0 -24
- package/build/cjs/integrations/childProcess.js.map +1 -1
- package/build/cjs/integrations/fs/vendored/instrumentation.js +4 -2
- package/build/cjs/integrations/fs/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +7 -12
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/cjs/integrations/http/httpServerIntegration.js +4 -3
- package/build/cjs/integrations/http/httpServerIntegration.js.map +1 -1
- package/build/cjs/integrations/http/httpServerSpansIntegration.js +38 -92
- package/build/cjs/integrations/http/httpServerSpansIntegration.js.map +1 -1
- package/build/cjs/integrations/http/index.js +16 -30
- package/build/cjs/integrations/http/index.js.map +1 -1
- package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/build/cjs/integrations/node-fetch/undici-instrumentation.js +15 -7
- package/build/cjs/integrations/node-fetch/undici-instrumentation.js.map +1 -1
- package/build/cjs/integrations/nodeRuntimeMetrics.js +2 -1
- package/build/cjs/integrations/nodeRuntimeMetrics.js.map +1 -1
- package/build/cjs/integrations/onunhandledrejection.js +5 -3
- package/build/cjs/integrations/onunhandledrejection.js.map +1 -1
- package/build/cjs/integrations/pino.js +2 -3
- package/build/cjs/integrations/pino.js.map +1 -1
- package/build/cjs/integrations/processSession.js +1 -1
- package/build/cjs/integrations/processSession.js.map +1 -1
- package/build/cjs/integrations/tracing/hapi.js +10 -0
- package/build/cjs/integrations/tracing/hapi.js.map +1 -0
- package/build/cjs/integrations/tracing/index.js +1 -34
- package/build/cjs/integrations/tracing/index.js.map +1 -1
- package/build/cjs/integrations/tracing/koa.js +10 -0
- package/build/cjs/integrations/tracing/koa.js.map +1 -0
- package/build/cjs/integrations/workerThreads.js +35 -0
- package/build/cjs/integrations/workerThreads.js.map +1 -0
- package/build/cjs/sdk/api.js +2 -1
- package/build/cjs/sdk/api.js.map +1 -1
- package/build/cjs/sdk/client.js +25 -14
- package/build/cjs/sdk/client.js.map +1 -1
- package/build/cjs/sdk/index.js +17 -30
- package/build/cjs/sdk/index.js.map +1 -1
- package/build/cjs/transports/http.js +10 -3
- package/build/cjs/transports/http.js.map +1 -1
- package/build/cjs/utils/outgoingFetchRequest.js +1 -1
- package/build/cjs/utils/outgoingFetchRequest.js.map +1 -1
- package/build/esm/bundler-plugin/esbuild.js.map +1 -1
- package/build/esm/bundler-plugin/rollup.js.map +1 -1
- package/build/esm/bundler-plugin/vite.js.map +1 -1
- package/build/esm/bundler-plugin/webpack.js.map +1 -1
- package/build/esm/index.js +7 -8
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/anr/index.js +1 -1
- package/build/esm/integrations/anr/worker-script.js +2 -2
- package/build/esm/integrations/childProcess.js +1 -25
- package/build/esm/integrations/childProcess.js.map +1 -1
- package/build/esm/integrations/fs/vendored/instrumentation.js +4 -2
- package/build/esm/integrations/fs/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +5 -10
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/esm/integrations/http/httpServerIntegration.js +3 -2
- package/build/esm/integrations/http/httpServerIntegration.js.map +1 -1
- package/build/esm/integrations/http/httpServerSpansIntegration.js +40 -94
- package/build/esm/integrations/http/httpServerSpansIntegration.js.map +1 -1
- package/build/esm/integrations/http/index.js +15 -29
- package/build/esm/integrations/http/index.js.map +1 -1
- package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
- package/build/esm/integrations/local-variables/worker-script.js +1 -1
- package/build/esm/integrations/node-fetch/undici-instrumentation.js +17 -9
- package/build/esm/integrations/node-fetch/undici-instrumentation.js.map +1 -1
- package/build/esm/integrations/nodeRuntimeMetrics.js +2 -1
- package/build/esm/integrations/nodeRuntimeMetrics.js.map +1 -1
- package/build/esm/integrations/onunhandledrejection.js +5 -3
- package/build/esm/integrations/onunhandledrejection.js.map +1 -1
- package/build/esm/integrations/pino.js +2 -3
- package/build/esm/integrations/pino.js.map +1 -1
- package/build/esm/integrations/processSession.js +1 -1
- package/build/esm/integrations/processSession.js.map +1 -1
- package/build/esm/integrations/tracing/hapi.js +8 -0
- package/build/esm/integrations/tracing/hapi.js.map +1 -0
- package/build/esm/integrations/tracing/index.js +2 -35
- package/build/esm/integrations/tracing/index.js.map +1 -1
- package/build/esm/integrations/tracing/koa.js +8 -0
- package/build/esm/integrations/tracing/koa.js.map +1 -0
- package/build/esm/integrations/workerThreads.js +33 -0
- package/build/esm/integrations/workerThreads.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/sdk/api.js +2 -1
- package/build/esm/sdk/api.js.map +1 -1
- package/build/esm/sdk/client.js +25 -14
- package/build/esm/sdk/client.js.map +1 -1
- package/build/esm/sdk/index.js +11 -24
- package/build/esm/sdk/index.js.map +1 -1
- package/build/esm/transports/http.js +10 -3
- package/build/esm/transports/http.js.map +1 -1
- package/build/esm/utils/outgoingFetchRequest.js +2 -2
- package/build/esm/utils/outgoingFetchRequest.js.map +1 -1
- package/build/import-hook.mjs +1 -1
- package/build/types/bundler-plugin/esbuild.d.ts +3 -4
- package/build/types/bundler-plugin/esbuild.d.ts.map +1 -1
- package/build/types/bundler-plugin/rollup.d.ts +3 -4
- package/build/types/bundler-plugin/rollup.d.ts.map +1 -1
- package/build/types/bundler-plugin/vite.d.ts +3 -4
- package/build/types/bundler-plugin/vite.d.ts.map +1 -1
- package/build/types/bundler-plugin/webpack.d.ts +2 -2
- package/build/types/bundler-plugin/webpack.d.ts.map +1 -1
- package/build/types/index.d.ts +7 -6
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/childProcess.d.ts +2 -7
- package/build/types/integrations/childProcess.d.ts.map +1 -1
- package/build/types/integrations/fs/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +8 -62
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/http/httpServerIntegration.d.ts +4 -3
- package/build/types/integrations/http/httpServerIntegration.d.ts.map +1 -1
- package/build/types/integrations/http/httpServerSpansIntegration.d.ts +2 -9
- package/build/types/integrations/http/httpServerSpansIntegration.d.ts.map +1 -1
- package/build/types/integrations/http/index.d.ts +16 -74
- package/build/types/integrations/http/index.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/undici-instrumentation.d.ts.map +1 -1
- package/build/types/integrations/nodeRuntimeMetrics.d.ts.map +1 -1
- package/build/types/integrations/pino.d.ts.map +1 -1
- package/build/types/integrations/tracing/hapi.d.ts +13 -0
- package/build/types/integrations/tracing/hapi.d.ts.map +1 -0
- package/build/types/integrations/tracing/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/koa.d.ts +27 -0
- package/build/types/integrations/tracing/koa.d.ts.map +1 -0
- package/build/types/integrations/workerThreads.d.ts +8 -0
- package/build/types/integrations/workerThreads.d.ts.map +1 -0
- package/build/types/sdk/api.d.ts.map +1 -1
- package/build/types/sdk/client.d.ts +3 -1
- package/build/types/sdk/client.d.ts.map +1 -1
- package/build/types/sdk/index.d.ts.map +1 -1
- package/build/types/transports/http.d.ts +1 -1
- package/build/types/transports/http.d.ts.map +1 -1
- package/build/types/types.d.ts +13 -1
- package/build/types/types.d.ts.map +1 -1
- package/package.json +8 -6
- package/build/cjs/integrations/tracing/express.js +0 -11
- package/build/cjs/integrations/tracing/express.js.map +0 -1
- package/build/cjs/integrations/tracing/fastify/index.js +0 -40
- package/build/cjs/integrations/tracing/fastify/index.js.map +0 -1
- package/build/cjs/integrations/tracing/hapi/index.js +0 -44
- package/build/cjs/integrations/tracing/hapi/index.js.map +0 -1
- package/build/cjs/integrations/tracing/koa/index.js +0 -22
- package/build/cjs/integrations/tracing/koa/index.js.map +0 -1
- package/build/cjs/integrations/tracing/redis/cache.js +0 -43
- package/build/cjs/integrations/tracing/redis/cache.js.map +0 -1
- package/build/cjs/integrations/tracing/redis/index.js +0 -34
- package/build/cjs/integrations/tracing/redis/index.js.map +0 -1
- package/build/cjs/utils/redisCache.js +0 -98
- package/build/cjs/utils/redisCache.js.map +0 -1
- package/build/esm/integrations/tracing/express.js +0 -9
- package/build/esm/integrations/tracing/express.js.map +0 -1
- package/build/esm/integrations/tracing/fastify/index.js +0 -37
- package/build/esm/integrations/tracing/fastify/index.js.map +0 -1
- package/build/esm/integrations/tracing/hapi/index.js +0 -41
- package/build/esm/integrations/tracing/hapi/index.js.map +0 -1
- package/build/esm/integrations/tracing/koa/index.js +0 -20
- package/build/esm/integrations/tracing/koa/index.js.map +0 -1
- package/build/esm/integrations/tracing/redis/cache.js +0 -40
- package/build/esm/integrations/tracing/redis/cache.js.map +0 -1
- package/build/esm/integrations/tracing/redis/index.js +0 -28
- package/build/esm/integrations/tracing/redis/index.js.map +0 -1
- package/build/esm/utils/redisCache.js +0 -89
- package/build/esm/utils/redisCache.js.map +0 -1
- package/build/types/integrations/tracing/express.d.ts +0 -6
- package/build/types/integrations/tracing/express.d.ts.map +0 -1
- package/build/types/integrations/tracing/fastify/index.d.ts +0 -115
- package/build/types/integrations/tracing/fastify/index.d.ts.map +0 -1
- package/build/types/integrations/tracing/fastify/types.d.ts +0 -33
- package/build/types/integrations/tracing/fastify/types.d.ts.map +0 -1
- package/build/types/integrations/tracing/hapi/index.d.ts +0 -29
- package/build/types/integrations/tracing/hapi/index.d.ts.map +0 -1
- package/build/types/integrations/tracing/hapi/types.d.ts +0 -166
- package/build/types/integrations/tracing/hapi/types.d.ts.map +0 -1
- package/build/types/integrations/tracing/koa/index.d.ts +0 -26
- package/build/types/integrations/tracing/koa/index.d.ts.map +0 -1
- package/build/types/integrations/tracing/redis/cache.d.ts +0 -22
- package/build/types/integrations/tracing/redis/cache.d.ts.map +0 -1
- package/build/types/integrations/tracing/redis/index.d.ts +0 -21
- package/build/types/integrations/tracing/redis/index.d.ts.map +0 -1
- package/build/types/integrations/tracing/redis/vendored/types.d.ts +0 -9
- package/build/types/integrations/tracing/redis/vendored/types.d.ts.map +0 -1
- package/build/types/utils/redisCache.d.ts +0 -17
- package/build/types/utils/redisCache.d.ts.map +0 -1
|
@@ -10,7 +10,7 @@ const processSessionIntegration = core.defineIntegration(() => {
|
|
|
10
10
|
core.startSession();
|
|
11
11
|
process.on("beforeExit", () => {
|
|
12
12
|
const session = core.getIsolationScope().getSession();
|
|
13
|
-
if (session?.status
|
|
13
|
+
if (session?.status === "ok") {
|
|
14
14
|
core.endSession();
|
|
15
15
|
}
|
|
16
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processSession.js","sources":["../../../src/integrations/processSession.ts"],"sourcesContent":["import { defineIntegration, endSession, getIsolationScope, startSession } from '@sentry/core';\n\nconst INTEGRATION_NAME = 'ProcessSession' as const;\n\n/**\n * Records a Session for the current process to track release health.\n */\nexport const processSessionIntegration = defineIntegration(() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n startSession();\n\n // Emitted in the case of healthy sessions, error of `mechanism.handled: true` and unhandledrejections because\n // The 'beforeExit' event is not emitted for conditions causing explicit termination,\n // such as calling process.exit() or uncaught exceptions.\n // Ref: https://nodejs.org/api/process.html#process_event_beforeexit\n process.on('beforeExit', () => {\n const session = getIsolationScope().getSession();\n\n // Only call endSession
|
|
1
|
+
{"version":3,"file":"processSession.js","sources":["../../../src/integrations/processSession.ts"],"sourcesContent":["import { defineIntegration, endSession, getIsolationScope, startSession } from '@sentry/core';\n\nconst INTEGRATION_NAME = 'ProcessSession' as const;\n\n/**\n * Records a Session for the current process to track release health.\n */\nexport const processSessionIntegration = defineIntegration(() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n startSession();\n\n // Emitted in the case of healthy sessions, error of `mechanism.handled: true` and unhandledrejections because\n // The 'beforeExit' event is not emitted for conditions causing explicit termination,\n // such as calling process.exit() or uncaught exceptions.\n // Ref: https://nodejs.org/api/process.html#process_event_beforeexit\n process.on('beforeExit', () => {\n const session = getIsolationScope().getSession();\n\n // Only call endSession if a Session exists on the Scope and has not already reached a\n // Terminal Status, because \"When a session is moved away from ok it must not be updated\n // anymore.\" `ok` is the only non-terminal status.\n // Ref: https://develop.sentry.dev/sdk/sessions/\n if (session?.status === 'ok') {\n endSession();\n }\n });\n },\n };\n});\n"],"names":["defineIntegration","startSession","getIsolationScope","endSession"],"mappings":";;;;AAEA,MAAM,gBAAA,GAAmB,gBAAA;AAKlB,MAAM,yBAAA,GAA4BA,uBAAkB,MAAM;AAC/D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAAC,iBAAA,EAAa;AAMb,MAAA,OAAA,CAAQ,EAAA,CAAG,cAAc,MAAM;AAC7B,QAAA,MAAM,OAAA,GAAUC,sBAAA,EAAkB,CAAE,UAAA,EAAW;AAM/C,QAAA,IAAI,OAAA,EAAS,WAAW,IAAA,EAAM;AAC5B,UAAAC,eAAA,EAAW;AAAA,QACb;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAC;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const serverUtils = require('@sentry/server-utils');
|
|
4
|
+
|
|
5
|
+
async function setupHapiErrorHandler(server) {
|
|
6
|
+
serverUtils.attachHapiErrorHandler(server);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
exports.setupHapiErrorHandler = setupHapiErrorHandler;
|
|
10
|
+
//# sourceMappingURL=hapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hapi.js","sources":["../../../../src/integrations/tracing/hapi.ts"],"sourcesContent":["import { attachHapiErrorHandler } from '@sentry/server-utils';\n\n/**\n * Add a Hapi plugin to capture errors to Sentry.\n *\n * @deprecated The error handler is now registered automatically when the Hapi\n * server starts (via the orchestrion `@hapi/hapi` instrumentation), so calling\n * this is no longer necessary. It remains a safe, idempotent operation when the\n * handler is already attached, and is kept for setups where auto-registration is\n * unavailable. This will be removed in a future major version.\n *\n * @param server The Hapi server to attach the error handler to\n */\nexport async function setupHapiErrorHandler(server: unknown): Promise<void> {\n // oxlint-disable-next-line typescript/no-deprecated\n attachHapiErrorHandler(server as Parameters<typeof attachHapiErrorHandler>[0]);\n}\n"],"names":["attachHapiErrorHandler"],"mappings":";;;;AAaA,eAAsB,sBAAsB,MAAA,EAAgC;AAE1E,EAAAA,kCAAA,CAAuB,MAAsD,CAAA;AAC/E;;;;"}
|
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const serverUtils = require('@sentry/server-utils');
|
|
4
|
-
const orchestrion = require('@sentry/server-utils/orchestrion');
|
|
5
|
-
const index = require('./fastify/index.js');
|
|
6
|
-
const index$1 = require('./redis/index.js');
|
|
7
4
|
|
|
8
5
|
function getAutoPerformanceIntegrations() {
|
|
9
|
-
return
|
|
10
|
-
orchestrion.expressIntegration(),
|
|
11
|
-
index.fastifyIntegration(),
|
|
12
|
-
orchestrion.graphqlDiagnosticsIntegration(),
|
|
13
|
-
orchestrion.mongodbIntegration(),
|
|
14
|
-
orchestrion.mongooseIntegration(),
|
|
15
|
-
orchestrion.mysqlIntegration(),
|
|
16
|
-
orchestrion.mysql2Integration(),
|
|
17
|
-
// Redis keeps the node wrapper: it wires the cache `responseHook` into the channel subscribers
|
|
18
|
-
// and covers all redis client versions (native diagnostics_channel + orchestrion fallbacks).
|
|
19
|
-
index$1.redisIntegration(),
|
|
20
|
-
orchestrion.postgresIntegration(),
|
|
21
|
-
serverUtils.prismaIntegration(),
|
|
22
|
-
orchestrion.hapiIntegration(),
|
|
23
|
-
orchestrion.koaIntegration(),
|
|
24
|
-
orchestrion.tediousIntegration(),
|
|
25
|
-
orchestrion.genericPoolIntegration(),
|
|
26
|
-
orchestrion.kafkajsIntegration(),
|
|
27
|
-
orchestrion.amqplibIntegration(),
|
|
28
|
-
orchestrion.lruMemoizerIntegration(),
|
|
29
|
-
// AI providers
|
|
30
|
-
// LangChain must come first to disable AI provider integrations before they instrument
|
|
31
|
-
orchestrion.langChainIntegration(),
|
|
32
|
-
orchestrion.langGraphIntegration(),
|
|
33
|
-
orchestrion.vercelAiIntegration(),
|
|
34
|
-
orchestrion.openaiIntegration(),
|
|
35
|
-
orchestrion.anthropicIntegration(),
|
|
36
|
-
orchestrion.googleGenAIIntegration(),
|
|
37
|
-
orchestrion.postgresJsIntegration(),
|
|
38
|
-
orchestrion.firebaseIntegration()
|
|
39
|
-
];
|
|
6
|
+
return serverUtils.getTracingIntegrations();
|
|
40
7
|
}
|
|
41
8
|
|
|
42
9
|
exports.getAutoPerformanceIntegrations = getAutoPerformanceIntegrations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { getTracingIntegrations } from '@sentry/server-utils';\n\nexport function getAutoPerformanceIntegrations(): Integration[] {\n return getTracingIntegrations();\n}\n"],"names":["getTracingIntegrations"],"mappings":";;;;AAGO,SAAS,8BAAA,GAAgD;AAC9D,EAAA,OAAOA,kCAAA,EAAuB;AAChC;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const serverUtils = require('@sentry/server-utils');
|
|
4
|
+
|
|
5
|
+
const setupKoaErrorHandler = (app) => {
|
|
6
|
+
serverUtils.attachKoaErrorHandler(app);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
exports.setupKoaErrorHandler = setupKoaErrorHandler;
|
|
10
|
+
//# sourceMappingURL=koa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"koa.js","sources":["../../../../src/integrations/tracing/koa.ts"],"sourcesContent":["import { attachKoaErrorHandler } from '@sentry/server-utils';\n\n/**\n * Add a Koa error handler to capture errors to Sentry.\n *\n * @deprecated The error handler is now registered automatically when the Koa app\n * starts (via the orchestrion `koa` instrumentation), so calling this is no\n * longer necessary. It remains a safe, idempotent operation, and is kept for\n * setups where auto-registration is unavailable. This will be removed in a\n * future major version.\n *\n * @param app The Koa app instance\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const Koa = require(\"koa\");\n *\n * const app = new Koa();\n *\n * // Add your routes, etc.\n *\n * app.listen(3000);\n * ```\n */\n\nexport const setupKoaErrorHandler = (app: {\n // oxlint-disable-next-line no-explicit-any\n on: (event: 'error', listener: (...args: any[]) => void) => unknown;\n}): void => {\n // oxlint-disable-next-line typescript/no-deprecated -- internal delegation to the shared implementation\n attachKoaErrorHandler(app);\n};\n"],"names":["attachKoaErrorHandler"],"mappings":";;;;AA0BO,MAAM,oBAAA,GAAuB,CAAC,GAAA,KAGzB;AAEV,EAAAA,iCAAA,CAAsB,GAAG,CAAA;AAC3B;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const diagnosticsChannel = require('node:diagnostics_channel');
|
|
4
|
+
const core = require('@sentry/core');
|
|
5
|
+
|
|
6
|
+
const INTEGRATION_NAME = "WorkerThreads";
|
|
7
|
+
const workerThreadsIntegration = core.defineIntegration(() => {
|
|
8
|
+
return {
|
|
9
|
+
name: INTEGRATION_NAME,
|
|
10
|
+
setup() {
|
|
11
|
+
diagnosticsChannel.channel("worker_threads").subscribe((event) => {
|
|
12
|
+
if (core.isObjectLike(event) && "worker" in event) {
|
|
13
|
+
captureWorkerThreadEvents(event.worker);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
function captureWorkerThreadEvents(worker) {
|
|
20
|
+
let threadId;
|
|
21
|
+
worker.on("online", () => {
|
|
22
|
+
threadId = worker.threadId;
|
|
23
|
+
}).on("error", (error) => {
|
|
24
|
+
core.captureException(error, {
|
|
25
|
+
mechanism: {
|
|
26
|
+
type: "auto.node.worker_threads",
|
|
27
|
+
handled: false,
|
|
28
|
+
data: threadId !== void 0 ? { threadId: String(threadId) } : void 0
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.workerThreadsIntegration = workerThreadsIntegration;
|
|
35
|
+
//# sourceMappingURL=workerThreads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerThreads.js","sources":["../../../src/integrations/workerThreads.ts"],"sourcesContent":["import type { Worker } from 'node:worker_threads';\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { captureException, defineIntegration, isObjectLike } from '@sentry/core';\n\nconst INTEGRATION_NAME = 'WorkerThreads' as const;\n\n/**\n * Capture events and errors of worker threads.\n * For child process events, use `childProcessIntegration()` instead.\n */\nexport const workerThreadsIntegration = defineIntegration(() => {\n return {\n name: INTEGRATION_NAME,\n setup() {\n diagnosticsChannel.channel('worker_threads').subscribe((event: unknown) => {\n if (isObjectLike(event) && 'worker' in event) {\n captureWorkerThreadEvents(event.worker as Worker);\n }\n });\n },\n };\n});\n\nfunction captureWorkerThreadEvents(worker: Worker): void {\n let threadId: number | undefined;\n\n worker\n .on('online', () => {\n threadId = worker.threadId;\n })\n .on('error', error => {\n captureException(error, {\n mechanism: {\n type: 'auto.node.worker_threads',\n handled: false,\n data: threadId !== undefined ? { threadId: String(threadId) } : undefined,\n },\n });\n });\n}\n"],"names":["defineIntegration","isObjectLike","captureException"],"mappings":";;;;;AAIA,MAAM,gBAAA,GAAmB,eAAA;AAMlB,MAAM,wBAAA,GAA2BA,uBAAkB,MAAM;AAC9D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,KAAA,GAAQ;AACN,MAAA,kBAAA,CAAmB,OAAA,CAAQ,gBAAgB,CAAA,CAAE,SAAA,CAAU,CAAC,KAAA,KAAmB;AACzE,QAAA,IAAIC,iBAAA,CAAa,KAAK,CAAA,IAAK,QAAA,IAAY,KAAA,EAAO;AAC5C,UAAA,yBAAA,CAA0B,MAAM,MAAgB,CAAA;AAAA,QAClD;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAC;AAED,SAAS,0BAA0B,MAAA,EAAsB;AACvD,EAAA,IAAI,QAAA;AAEJ,EAAA,MAAA,CACG,EAAA,CAAG,UAAU,MAAM;AAClB,IAAA,QAAA,GAAW,MAAA,CAAO,QAAA;AAAA,EACpB,CAAC,CAAA,CACA,EAAA,CAAG,OAAA,EAAS,CAAA,KAAA,KAAS;AACpB,IAAAC,qBAAA,CAAiB,KAAA,EAAO;AAAA,MACtB,SAAA,EAAW;AAAA,QACT,IAAA,EAAM,0BAAA;AAAA,QACN,OAAA,EAAS,KAAA;AAAA,QACT,IAAA,EAAM,aAAa,MAAA,GAAY,EAAE,UAAU,MAAA,CAAO,QAAQ,GAAE,GAAI;AAAA;AAClE,KACD,CAAA;AAAA,EACH,CAAC,CAAA;AACL;;;;"}
|
package/build/cjs/sdk/api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
|
+
const server = require('@sentry/core/server');
|
|
4
5
|
const module$1 = require('../utils/module.js');
|
|
5
6
|
|
|
6
7
|
function getSentryRelease(fallback) {
|
|
@@ -54,7 +55,7 @@ function getSentryRelease(fallback) {
|
|
|
54
55
|
);
|
|
55
56
|
return possibleReleaseNameOfGitProvider || possibleReleaseNameOfCiProvidersWithSpecificEnvVar || possibleReleaseNameOfCiProvidersWithGenericEnvVar || fallback;
|
|
56
57
|
}
|
|
57
|
-
const defaultStackParser = core.createStackParser(
|
|
58
|
+
const defaultStackParser = core.createStackParser(server.nodeStackLineParser(module$1.createGetModuleFromFilename()));
|
|
58
59
|
|
|
59
60
|
exports.defaultStackParser = defaultStackParser;
|
|
60
61
|
exports.getSentryRelease = getSentryRelease;
|
package/build/cjs/sdk/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sources":["../../../src/sdk/api.ts"],"sourcesContent":["// PUBLIC APIS\n\nimport type { StackParser } from '@sentry/core';\nimport { createStackParser, GLOBAL_OBJ
|
|
1
|
+
{"version":3,"file":"api.js","sources":["../../../src/sdk/api.ts"],"sourcesContent":["// PUBLIC APIS\n\nimport type { StackParser } from '@sentry/core';\nimport { createStackParser, GLOBAL_OBJ } from '@sentry/core';\nimport { nodeStackLineParser } from '@sentry/core/server';\nimport { createGetModuleFromFilename } from '../utils/module';\n\n/**\n * Returns a release dynamically from environment variables.\n */\n// eslint-disable-next-line complexity\nexport function getSentryRelease(fallback?: string): string | undefined {\n // Always read first as Sentry takes this as precedence\n if (process.env.SENTRY_RELEASE) {\n return process.env.SENTRY_RELEASE;\n }\n\n // This supports the variable that sentry-webpack-plugin injects\n if (GLOBAL_OBJ.SENTRY_RELEASE?.id) {\n return GLOBAL_OBJ.SENTRY_RELEASE.id;\n }\n\n // This list is in approximate alpha order, separated into 3 categories:\n // 1. Git providers\n // 2. CI providers with specific environment variables (has the provider name in the variable name)\n // 3. CI providers with generic environment variables (checked for last to prevent possible false positives)\n\n const possibleReleaseNameOfGitProvider =\n // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables\n process.env['GITHUB_SHA'] ||\n // GitLab CI - https://docs.gitlab.com/ee/ci/variables/predefined_variables.html\n process.env['CI_MERGE_REQUEST_SOURCE_BRANCH_SHA'] ||\n process.env['CI_BUILD_REF'] ||\n process.env['CI_COMMIT_SHA'] ||\n // Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/\n process.env['BITBUCKET_COMMIT'];\n\n const possibleReleaseNameOfCiProvidersWithSpecificEnvVar =\n // AppVeyor - https://www.appveyor.com/docs/environment-variables/\n process.env['APPVEYOR_PULL_REQUEST_HEAD_COMMIT'] ||\n process.env['APPVEYOR_REPO_COMMIT'] ||\n // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html\n process.env['CODEBUILD_RESOLVED_SOURCE_VERSION'] ||\n // AWS Amplify - https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html\n process.env['AWS_COMMIT_ID'] ||\n // Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml\n process.env['BUILD_SOURCEVERSION'] ||\n // Bitrise - https://devcenter.bitrise.io/builds/available-environment-variables/\n process.env['GIT_CLONE_COMMIT_HASH'] ||\n // Buddy CI - https://buddy.works/docs/pipelines/environment-variables#default-environment-variables\n process.env['BUDDY_EXECUTION_REVISION'] ||\n // Builtkite - https://buildkite.com/docs/pipelines/environment-variables\n process.env['BUILDKITE_COMMIT'] ||\n // CircleCI - https://circleci.com/docs/variables/\n process.env['CIRCLE_SHA1'] ||\n // Cirrus CI - https://cirrus-ci.org/guide/writing-tasks/#environment-variables\n process.env['CIRRUS_CHANGE_IN_REPO'] ||\n // Codefresh - https://codefresh.io/docs/docs/codefresh-yaml/variables/\n process.env['CF_REVISION'] ||\n // Codemagic - https://docs.codemagic.io/yaml-basic-configuration/environment-variables/\n process.env['CM_COMMIT'] ||\n // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables\n process.env['CF_PAGES_COMMIT_SHA'] ||\n // Drone - https://docs.drone.io/pipeline/environment/reference/\n process.env['DRONE_COMMIT_SHA'] ||\n // Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables\n process.env['FC_GIT_COMMIT_SHA'] ||\n // Heroku #1 https://devcenter.heroku.com/articles/heroku-ci\n process.env['HEROKU_TEST_RUN_COMMIT_VERSION'] ||\n // Heroku #2 https://devcenter.heroku.com/articles/dyno-metadata#dyno-metadata\n process.env['HEROKU_BUILD_COMMIT'] ||\n // Heroku #3 (deprecated by Heroku, kept for backward compatibility)\n process.env['HEROKU_SLUG_COMMIT'] ||\n // Railway - https://docs.railway.app/reference/variables#git-variables\n process.env['RAILWAY_GIT_COMMIT_SHA'] ||\n // Render - https://render.com/docs/environment-variables\n process.env['RENDER_GIT_COMMIT'] ||\n // Semaphore CI - https://docs.semaphoreci.com/ci-cd-environment/environment-variables\n process.env['SEMAPHORE_GIT_SHA'] ||\n // TravisCI - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables\n process.env['TRAVIS_PULL_REQUEST_SHA'] ||\n // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables\n process.env['VERCEL_GIT_COMMIT_SHA'] ||\n process.env['VERCEL_GITHUB_COMMIT_SHA'] ||\n process.env['VERCEL_GITLAB_COMMIT_SHA'] ||\n process.env['VERCEL_BITBUCKET_COMMIT_SHA'] ||\n // Zeit (now known as Vercel)\n process.env['ZEIT_GITHUB_COMMIT_SHA'] ||\n process.env['ZEIT_GITLAB_COMMIT_SHA'] ||\n process.env['ZEIT_BITBUCKET_COMMIT_SHA'];\n\n const possibleReleaseNameOfCiProvidersWithGenericEnvVar =\n // CloudBees CodeShip - https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables\n process.env['CI_COMMIT_ID'] ||\n // Coolify - https://coolify.io/docs/knowledge-base/environment-variables\n process.env['SOURCE_COMMIT'] ||\n // Heroku #3 https://devcenter.heroku.com/changelog-items/630\n process.env['SOURCE_VERSION'] ||\n // Jenkins - https://plugins.jenkins.io/git/#environment-variables\n process.env['GIT_COMMIT'] ||\n // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata\n process.env['COMMIT_REF'] ||\n // TeamCity - https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html\n process.env['BUILD_VCS_NUMBER'] ||\n // Woodpecker CI - https://woodpecker-ci.org/docs/usage/environment\n process.env['CI_COMMIT_SHA'];\n\n return (\n possibleReleaseNameOfGitProvider ||\n possibleReleaseNameOfCiProvidersWithSpecificEnvVar ||\n possibleReleaseNameOfCiProvidersWithGenericEnvVar ||\n fallback\n );\n}\n\n/** Node.js stack parser */\nexport const defaultStackParser: StackParser = createStackParser(nodeStackLineParser(createGetModuleFromFilename()));\n"],"names":["GLOBAL_OBJ","createStackParser","nodeStackLineParser","createGetModuleFromFilename"],"mappings":";;;;;;AAWO,SAAS,iBAAiB,QAAA,EAAuC;AAEtE,EAAA,IAAI,OAAA,CAAQ,IAAI,cAAA,EAAgB;AAC9B,IAAA,OAAO,QAAQ,GAAA,CAAI,cAAA;AAAA,EACrB;AAGA,EAAA,IAAIA,eAAA,CAAW,gBAAgB,EAAA,EAAI;AACjC,IAAA,OAAOA,gBAAW,cAAA,CAAe,EAAA;AAAA,EACnC;AAOA,EAAA,MAAM,gCAAA;AAAA;AAAA,IAEJ,OAAA,CAAQ,IAAI,YAAY,CAAA;AAAA,IAExB,OAAA,CAAQ,GAAA,CAAI,oCAAoC,CAAA,IAChD,OAAA,CAAQ,IAAI,cAAc,CAAA,IAC1B,OAAA,CAAQ,GAAA,CAAI,eAAe,CAAA;AAAA,IAE3B,OAAA,CAAQ,IAAI,kBAAkB;AAAA,GAAA;AAEhC,EAAA,MAAM,kDAAA;AAAA;AAAA,IAEJ,QAAQ,GAAA,CAAI,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IAAI,wBAAwB,CAAA,IACpC,OAAA,CAAQ,GAAA,CAAI,2BAA2B;AAAA,GAAA;AAEzC,EAAA,MAAM,iDAAA;AAAA;AAAA,IAEJ,OAAA,CAAQ,IAAI,cAAc,CAAA;AAAA,IAE1B,OAAA,CAAQ,IAAI,eAAe,CAAA;AAAA,IAE3B,OAAA,CAAQ,IAAI,gBAAgB,CAAA;AAAA,IAE5B,OAAA,CAAQ,IAAI,YAAY,CAAA;AAAA,IAExB,OAAA,CAAQ,IAAI,YAAY,CAAA;AAAA,IAExB,OAAA,CAAQ,IAAI,kBAAkB,CAAA;AAAA,IAE9B,OAAA,CAAQ,IAAI,eAAe;AAAA,GAAA;AAE7B,EAAA,OACE,gCAAA,IACA,sDACA,iDAAA,IACA,QAAA;AAEJ;AAGO,MAAM,kBAAA,GAAkCC,sBAAA,CAAkBC,0BAAA,CAAoBC,oCAAA,EAA6B,CAAC;;;;;"}
|
package/build/cjs/sdk/client.js
CHANGED
|
@@ -3,11 +3,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const os = require('node:os');
|
|
4
4
|
const api = require('@opentelemetry/api');
|
|
5
5
|
const core = require('@sentry/core');
|
|
6
|
+
const server = require('@sentry/core/server');
|
|
7
|
+
const opentelemetry = require('@sentry/opentelemetry');
|
|
8
|
+
const serverUtils = require('@sentry/server-utils');
|
|
6
9
|
const worker_threads = require('worker_threads');
|
|
7
10
|
const debugBuild = require('../debug-build.js');
|
|
8
11
|
|
|
9
12
|
const DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS = 6e4;
|
|
10
|
-
class NodeClient extends
|
|
13
|
+
class NodeClient extends server.ServerRuntimeClient {
|
|
11
14
|
constructor(options) {
|
|
12
15
|
const serverName = options.includeServerName === false ? void 0 : options.serverName || global.process.env.SENTRY_NAME || os.hostname();
|
|
13
16
|
const clientOptions = {
|
|
@@ -20,21 +23,29 @@ class NodeClient extends core.ServerRuntimeClient {
|
|
|
20
23
|
core.applySdkMetadata(clientOptions, "node");
|
|
21
24
|
core.debug.log(`Initializing Sentry: process: ${process.pid}, thread: ${worker_threads.isMainThread ? "main" : `worker-${worker_threads.threadId}`}.`);
|
|
22
25
|
super(clientOptions);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
log.attributes
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
process.on("beforeExit", this._logOnExitFlushListener);
|
|
26
|
+
this._logOnExitFlushListener = () => {
|
|
27
|
+
core._INTERNAL_flushLogsBuffer(this);
|
|
28
|
+
};
|
|
29
|
+
if (serverName) {
|
|
30
|
+
this.on("beforeCaptureLog", (log) => {
|
|
31
|
+
log.attributes = {
|
|
32
|
+
...log.attributes,
|
|
33
|
+
"server.address": serverName
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
36
|
}
|
|
37
|
+
process.on("beforeExit", this._logOnExitFlushListener);
|
|
37
38
|
core._INTERNAL_setDeferSegmentSpanCapture(this);
|
|
39
|
+
opentelemetry.registerPrepareSpanScope(this);
|
|
40
|
+
}
|
|
41
|
+
/** @inheritDoc */
|
|
42
|
+
init() {
|
|
43
|
+
if (this.getOptions().enableOpenTelemetrySetup) {
|
|
44
|
+
this.asyncLocalStorageLookup = opentelemetry.setOpenTelemetryContextAsyncContextStrategy();
|
|
45
|
+
} else {
|
|
46
|
+
this.asyncLocalStorageLookup = { asyncLocalStorage: serverUtils.setAsyncLocalStorageAsyncContextStrategy() };
|
|
47
|
+
}
|
|
48
|
+
super.init();
|
|
38
49
|
}
|
|
39
50
|
/** Get the OTEL tracer. */
|
|
40
51
|
get tracer() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../src/sdk/client.ts"],"sourcesContent":["import * as os from 'node:os';\nimport type { Tracer } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport type { ServerRuntimeClientOptions } from '@sentry/core';\nimport {\n _INTERNAL_clearAiProviderSkips,\n _INTERNAL_flushLogsBuffer,\n _INTERNAL_setDeferSegmentSpanCapture,\n applySdkMetadata,\n debug,\n SDK_VERSION,\n ServerRuntimeClient,\n} from '@sentry/core';\nimport { type AsyncLocalStorageLookup, type SentryTracerProvider } from '@sentry/opentelemetry';\nimport { isMainThread, threadId } from 'worker_threads';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { NodeClientOptions } from '../types';\n\nconst DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS = 60_000; // 60s was chosen arbitrarily\n\n/** A client for using Sentry with Node & OpenTelemetry. */\nexport class NodeClient extends ServerRuntimeClient<NodeClientOptions> {\n public traceProvider: SentryTracerProvider | undefined;\n public asyncLocalStorageLookup: AsyncLocalStorageLookup | undefined;\n\n private _tracer: Tracer | undefined;\n private _clientReportInterval: NodeJS.Timeout | undefined;\n private _clientReportOnExitFlushListener: (() => void) | undefined;\n private _logOnExitFlushListener: (() => void) | undefined;\n\n public constructor(options: NodeClientOptions) {\n const serverName =\n options.includeServerName === false\n ? undefined\n : options.serverName || global.process.env.SENTRY_NAME || os.hostname();\n\n const clientOptions: ServerRuntimeClientOptions = {\n ...options,\n platform: 'node',\n // Use provided runtime or default to 'node' with current process version\n runtime: options.runtime || { name: 'node', version: global.process.version },\n serverName,\n };\n\n applySdkMetadata(clientOptions, 'node');\n\n debug.log(`Initializing Sentry: process: ${process.pid}, thread: ${isMainThread ? 'main' : `worker-${threadId}`}.`);\n\n super(clientOptions);\n\n if (this.getOptions().enableLogs) {\n this._logOnExitFlushListener = () => {\n _INTERNAL_flushLogsBuffer(this);\n };\n\n if (serverName) {\n this.on('beforeCaptureLog', log => {\n log.attributes = {\n ...log.attributes,\n 'server.address': serverName,\n };\n });\n }\n\n process.on('beforeExit', this._logOnExitFlushListener);\n }\n\n // Enable deferred segment-span transaction capture here, in the constructor, rather than in\n // `initOtel`. Every client runs its constructor exactly once, whereas `initOtel` only runs on\n // `Sentry.init()` and only fully wires up the first client (a second `init` loses the\n // `setGlobalTracerProvider` race and bails early, and a manually constructed `NodeClient` never\n // runs `initOtel` at all). Anchoring on the constructor means every client — first, second, or\n // manual — defers correctly. It's unconditional and cheap: clients on the OpenTelemetry SDK\n // provider path produce OTel spans that never reach `SentrySpan`, so the strategy is simply never\n // consulted for them.\n _INTERNAL_setDeferSegmentSpanCapture(this);\n }\n\n /** Get the OTEL tracer. */\n public get tracer(): Tracer {\n if (this._tracer) {\n return this._tracer;\n }\n\n const name = '@sentry/node';\n const version = SDK_VERSION;\n const tracer = trace.getTracer(name, version);\n this._tracer = tracer;\n\n return tracer;\n }\n\n /** @inheritDoc */\n // @ts-expect-error - PromiseLike is a subset of Promise\n public async flush(timeout?: number): PromiseLike<boolean> {\n await this.traceProvider?.forceFlush();\n\n if (this.getOptions().sendClientReports) {\n this._flushOutcomes();\n }\n\n return super.flush(timeout);\n }\n\n /** @inheritDoc */\n // @ts-expect-error - PromiseLike is a subset of Promise\n public async close(timeout?: number | undefined): PromiseLike<boolean> {\n if (this._clientReportInterval) {\n clearInterval(this._clientReportInterval);\n }\n\n if (this._clientReportOnExitFlushListener) {\n process.off('beforeExit', this._clientReportOnExitFlushListener);\n }\n\n if (this._logOnExitFlushListener) {\n process.off('beforeExit', this._logOnExitFlushListener);\n }\n\n const allEventsSent = await super.close(timeout);\n if (this.traceProvider) {\n await this.traceProvider.shutdown();\n }\n\n return allEventsSent;\n }\n\n /**\n * Will start tracking client reports for this client.\n *\n * NOTICE: This method will create an interval that is periodically called and attach a `process.on('beforeExit')`\n * hook. To clean up these resources, call `.close()` when you no longer intend to use the client. Not doing so will\n * result in a memory leak.\n */\n // The reason client reports need to be manually activated with this method instead of just enabling them in a\n // constructor, is that if users periodically and unboundedly create new clients, we will create more and more\n // intervals and beforeExit listeners, thus leaking memory. In these situations, users are required to call\n // `client.close()` in order to dispose of the acquired resources.\n // We assume that calling this method in Sentry.init() is a sensible default, because calling Sentry.init() over and\n // over again would also result in memory leaks.\n // Note: We have experimented with using `FinalizationRegisty` to clear the interval when the client is garbage\n // collected, but it did not work, because the cleanup function never got called.\n public startClientReportTracking(): void {\n const clientOptions = this.getOptions();\n if (clientOptions.sendClientReports) {\n this._clientReportOnExitFlushListener = () => {\n this._flushOutcomes();\n };\n\n this._clientReportInterval = setInterval(() => {\n DEBUG_BUILD && debug.log('Flushing client reports based on interval.');\n this._flushOutcomes();\n }, clientOptions.clientReportFlushInterval ?? DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS)\n // Unref is critical for not preventing the process from exiting because the interval is active.\n .unref();\n\n process.on('beforeExit', this._clientReportOnExitFlushListener);\n }\n }\n\n /** @inheritDoc */\n protected _setupIntegrations(): void {\n // Clear AI provider skip registrations before setting up integrations\n // This ensures a clean state between different client initializations\n // (e.g., when LangChain skips OpenAI in one client, but a subsequent client uses OpenAI standalone)\n _INTERNAL_clearAiProviderSkips();\n super._setupIntegrations();\n }\n}\n"],"names":["ServerRuntimeClient","applySdkMetadata","debug","isMainThread","threadId","_INTERNAL_flushLogsBuffer","_INTERNAL_setDeferSegmentSpanCapture","SDK_VERSION","trace","DEBUG_BUILD","_INTERNAL_clearAiProviderSkips"],"mappings":";;;;;;;;AAkBA,MAAM,uCAAA,GAA0C,GAAA;AAGzC,MAAM,mBAAmBA,wBAAA,CAAuC;AAAA,EAS9D,YAAY,OAAA,EAA4B;AAC7C,IAAA,MAAM,UAAA,GACJ,OAAA,CAAQ,iBAAA,KAAsB,KAAA,GAC1B,MAAA,GACA,OAAA,CAAQ,UAAA,IAAc,MAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,WAAA,IAAe,EAAA,CAAG,QAAA,EAAS;AAE1E,IAAA,MAAM,aAAA,GAA4C;AAAA,MAChD,GAAG,OAAA;AAAA,MACH,QAAA,EAAU,MAAA;AAAA;AAAA,MAEV,OAAA,EAAS,QAAQ,OAAA,IAAW,EAAE,MAAM,MAAA,EAAQ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AA,IAAeP,UAAA,CAAM,IAAI,4CAA4C,CAAA;AACrE,QAAA,IAAA,CAAK,cAAA,EAAe;AAAA,MACtB,CAAA,EAAG,aAAA,CAAc,yBAAA,IAA6B,uCAAuC,EAElF,KAAA,EAAM;AAET,MAAA,OAAA,CAAQ,EAAA,CAAG,YAAA,EAAc,IAAA,CAAK,gCAAgC,CAAA;AAAA,IAChE;AAAA,EACF;AAAA;AAAA,EAGU,kBAAA,GAA2B;AAInC,IAAAQ,mCAAA,EAA+B;AAC/B,IAAA,KAAA,CAAM,kBAAA,EAAmB;AAAA,EAC3B;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../src/sdk/client.ts"],"sourcesContent":["import * as os from 'node:os';\nimport type { Tracer } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport type { ServerRuntimeClientOptions } from '@sentry/core/server';\nimport {\n _INTERNAL_clearAiProviderSkips,\n _INTERNAL_flushLogsBuffer,\n _INTERNAL_setDeferSegmentSpanCapture,\n applySdkMetadata,\n debug,\n SDK_VERSION,\n} from '@sentry/core';\nimport { ServerRuntimeClient } from '@sentry/core/server';\nimport {\n type AsyncLocalStorageLookup,\n registerPrepareSpanScope,\n type SentryTracerProvider,\n setOpenTelemetryContextAsyncContextStrategy,\n} from '@sentry/opentelemetry';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils';\nimport { isMainThread, threadId } from 'worker_threads';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { NodeClientOptions } from '../types';\n\nconst DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS = 60_000; // 60s was chosen arbitrarily\n\n/** A client for using Sentry with Node & OpenTelemetry. */\nexport class NodeClient extends ServerRuntimeClient<NodeClientOptions> {\n public traceProvider: SentryTracerProvider | undefined;\n public asyncLocalStorageLookup: AsyncLocalStorageLookup | undefined;\n\n private _tracer: Tracer | undefined;\n private _clientReportInterval: NodeJS.Timeout | undefined;\n private _clientReportOnExitFlushListener: (() => void) | undefined;\n private _logOnExitFlushListener: (() => void) | undefined;\n\n public constructor(options: NodeClientOptions) {\n const serverName =\n options.includeServerName === false\n ? undefined\n : options.serverName || global.process.env.SENTRY_NAME || os.hostname();\n\n const clientOptions: ServerRuntimeClientOptions = {\n ...options,\n platform: 'node',\n // Use provided runtime or default to 'node' with current process version\n runtime: options.runtime || { name: 'node', version: global.process.version },\n serverName,\n };\n\n applySdkMetadata(clientOptions, 'node');\n\n debug.log(`Initializing Sentry: process: ${process.pid}, thread: ${isMainThread ? 'main' : `worker-${threadId}`}.`);\n\n super(clientOptions);\n\n this._logOnExitFlushListener = () => {\n _INTERNAL_flushLogsBuffer(this);\n };\n\n if (serverName) {\n this.on('beforeCaptureLog', log => {\n log.attributes = {\n ...log.attributes,\n 'server.address': serverName,\n };\n });\n }\n\n process.on('beforeExit', this._logOnExitFlushListener);\n\n // Enable deferred segment-span transaction capture here, in the constructor, rather than in\n // `initOtel`. Every client runs its constructor exactly once, whereas `initOtel` only runs on\n // `Sentry.init()` and only fully wires up the first client (a second `init` loses the\n // `setGlobalTracerProvider` race and bails early, and a manually constructed `NodeClient` never\n // runs `initOtel` at all). Anchoring on the constructor means every client — first, second, or\n // manual — defers correctly. It's unconditional and cheap: clients on the OpenTelemetry SDK\n // provider path produce OTel spans that never reach `SentrySpan`, so the strategy is simply never\n // consulted for them.\n _INTERNAL_setDeferSegmentSpanCapture(this);\n\n // Same constructor anchoring as above: every client must continue incoming (remote) traces,\n // also manually constructed ones that never run `initOtel`.\n registerPrepareSpanScope(this);\n }\n\n /** @inheritDoc */\n public init(): void {\n // Must run before `super.init()`: channel-based integrations capture the strategy's\n // AsyncLocalStorage via `getTracingChannelBinding()` during integration setup.\n if (this.getOptions().enableOpenTelemetrySetup) {\n this.asyncLocalStorageLookup = setOpenTelemetryContextAsyncContextStrategy();\n } else {\n this.asyncLocalStorageLookup = { asyncLocalStorage: setAsyncLocalStorageAsyncContextStrategy() };\n }\n\n super.init();\n }\n\n /** Get the OTEL tracer. */\n public get tracer(): Tracer {\n if (this._tracer) {\n return this._tracer;\n }\n\n const name = '@sentry/node';\n const version = SDK_VERSION;\n const tracer = trace.getTracer(name, version);\n this._tracer = tracer;\n\n return tracer;\n }\n\n /** @inheritDoc */\n // @ts-expect-error - PromiseLike is a subset of Promise\n public async flush(timeout?: number): PromiseLike<boolean> {\n await this.traceProvider?.forceFlush();\n\n if (this.getOptions().sendClientReports) {\n this._flushOutcomes();\n }\n\n return super.flush(timeout);\n }\n\n /** @inheritDoc */\n // @ts-expect-error - PromiseLike is a subset of Promise\n public async close(timeout?: number | undefined): PromiseLike<boolean> {\n if (this._clientReportInterval) {\n clearInterval(this._clientReportInterval);\n }\n\n if (this._clientReportOnExitFlushListener) {\n process.off('beforeExit', this._clientReportOnExitFlushListener);\n }\n\n if (this._logOnExitFlushListener) {\n process.off('beforeExit', this._logOnExitFlushListener);\n }\n\n const allEventsSent = await super.close(timeout);\n if (this.traceProvider) {\n await this.traceProvider.shutdown();\n }\n\n return allEventsSent;\n }\n\n /**\n * Will start tracking client reports for this client.\n *\n * NOTICE: This method will create an interval that is periodically called and attach a `process.on('beforeExit')`\n * hook. To clean up these resources, call `.close()` when you no longer intend to use the client. Not doing so will\n * result in a memory leak.\n */\n // The reason client reports need to be manually activated with this method instead of just enabling them in a\n // constructor, is that if users periodically and unboundedly create new clients, we will create more and more\n // intervals and beforeExit listeners, thus leaking memory. In these situations, users are required to call\n // `client.close()` in order to dispose of the acquired resources.\n // We assume that calling this method in Sentry.init() is a sensible default, because calling Sentry.init() over and\n // over again would also result in memory leaks.\n // Note: We have experimented with using `FinalizationRegisty` to clear the interval when the client is garbage\n // collected, but it did not work, because the cleanup function never got called.\n public startClientReportTracking(): void {\n const clientOptions = this.getOptions();\n if (clientOptions.sendClientReports) {\n this._clientReportOnExitFlushListener = () => {\n this._flushOutcomes();\n };\n\n this._clientReportInterval = setInterval(() => {\n DEBUG_BUILD && debug.log('Flushing client reports based on interval.');\n this._flushOutcomes();\n }, clientOptions.clientReportFlushInterval ?? DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS)\n // Unref is critical for not preventing the process from exiting because the interval is active.\n .unref();\n\n process.on('beforeExit', this._clientReportOnExitFlushListener);\n }\n }\n\n /** @inheritDoc */\n protected _setupIntegrations(): void {\n // Clear AI provider skip registrations before setting up integrations\n // This ensures a clean state between different client initializations\n // (e.g., when LangChain skips OpenAI in one client, but a subsequent client uses OpenAI standalone)\n _INTERNAL_clearAiProviderSkips();\n super._setupIntegrations();\n }\n}\n"],"names":["ServerRuntimeClient","applySdkMetadata","debug","isMainThread","threadId","_INTERNAL_flushLogsBuffer","_INTERNAL_setDeferSegmentSpanCapture","registerPrepareSpanScope","setOpenTelemetryContextAsyncContextStrategy","setAsyncLocalStorageAsyncContextStrategy","SDK_VERSION","trace","DEBUG_BUILD","_INTERNAL_clearAiProviderSkips"],"mappings":";;;;;;;;;;;AAwBA,MAAM,uCAAA,GAA0C,GAAA;AAGzC,MAAM,mBAAmBA,0BAAA,CAAuC;AAAA,EAS9D,YAAY,OAAA,EAA4B;AAC7C,IAAA,MAAM,UAAA,GACJ,OAAA,CAAQ,iBAAA,KAAsB,KAAA,GAC1B,MAAA,GACA,OAAA,CAAQ,UAAA,IAAc,MAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,WAAA,IAAe,EAAA,CAAG,QAAA,EAAS;AAE1E,IAAA,MAAM,aAAA,GAA4C;AAAA,MAChD,GAAG,OAAA;AAAA,MACH,QAAA,EAAU,MAAA;AAAA;AAAA,MAEV,OAAA,EAAS,QAAQ,OAAA,IAAW,EAAE,MAAM,MAAA,EAAQ,OAAA,EAAS,MAAA,CAAO,OAAA,CAAQ,OAAA,EAAQ;AAAA,MAC5E;AAAA,KACF;AAEA,IAAAC,qBAAA,CAAiB,eAAe,MAAM,CAAA;AAEtC,IAAAC,UAAA,CAAM,GAAA,CAAI,CAAA,8BAAA,EAAiC,OAAA,CAAQ,GAAG,CAAA,UAAA,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A,MAAA,IAAA,CAAK,qBAAA,GAAwB,YAAY,MAAM;AAC7C,QAAAC,sBAAA,IAAeV,UAAA,CAAM,IAAI,4CAA4C,CAAA;AACrE,QAAA,IAAA,CAAK,cAAA,EAAe;AAAA,MACtB,CAAA,EAAG,aAAA,CAAc,yBAAA,IAA6B,uCAAuC,EAElF,KAAA,EAAM;AAET,MAAA,OAAA,CAAQ,EAAA,CAAG,YAAA,EAAc,IAAA,CAAK,gCAAgC,CAAA;AAAA,IAChE;AAAA,EACF;AAAA;AAAA,EAGU,kBAAA,GAA2B;AAInC,IAAAW,mCAAA,EAA+B;AAC/B,IAAA,KAAA,CAAM,kBAAA,EAAmB;AAAA,EAC3B;AACF;;;;"}
|
package/build/cjs/sdk/index.js
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
|
-
const opentelemetry = require('@sentry/opentelemetry');
|
|
5
|
-
const serverUtils = require('@sentry/server-utils');
|
|
6
4
|
const node_worker_threads = require('node:worker_threads');
|
|
7
|
-
const
|
|
8
|
-
const register = require('@sentry/server-
|
|
5
|
+
const serverUtils = require('@sentry/server-utils');
|
|
6
|
+
const register = require('@sentry/server-runtime-injection/register');
|
|
9
7
|
const debugBuild = require('../debug-build.js');
|
|
10
8
|
const childProcess = require('../integrations/childProcess.js');
|
|
11
9
|
const console$1 = require('../integrations/console.js');
|
|
12
10
|
const context = require('../integrations/context.js');
|
|
13
11
|
const contextlines = require('../integrations/contextlines.js');
|
|
14
|
-
const index
|
|
15
|
-
const index$
|
|
12
|
+
const index = require('../integrations/http/index.js');
|
|
13
|
+
const index$2 = require('../integrations/local-variables/index.js');
|
|
16
14
|
const modules = require('../integrations/modules.js');
|
|
17
|
-
const index$
|
|
15
|
+
const index$1 = require('../integrations/node-fetch/index.js');
|
|
18
16
|
const onuncaughtexception = require('../integrations/onuncaughtexception.js');
|
|
19
17
|
const onunhandledrejection = require('../integrations/onunhandledrejection.js');
|
|
20
18
|
const processSession = require('../integrations/processSession.js');
|
|
21
19
|
const spotlight = require('../integrations/spotlight.js');
|
|
22
20
|
const systemError = require('../integrations/systemError.js');
|
|
23
|
-
const
|
|
21
|
+
const workerThreads = require('../integrations/workerThreads.js');
|
|
24
22
|
const http = require('../transports/http.js');
|
|
25
23
|
const entryPoint = require('../utils/entry-point.js');
|
|
26
24
|
const spotlight$1 = require('../utils/spotlight.js');
|
|
@@ -39,18 +37,21 @@ function getBaseDefaultIntegrations() {
|
|
|
39
37
|
core.conversationIdIntegration(),
|
|
40
38
|
// Native Wrappers
|
|
41
39
|
console$1.consoleIntegration(),
|
|
42
|
-
index
|
|
43
|
-
index$
|
|
40
|
+
index.httpIntegration(),
|
|
41
|
+
index$1.nativeNodeFetchIntegration(),
|
|
44
42
|
// Global Handlers
|
|
45
43
|
onuncaughtexception.onUncaughtExceptionIntegration(),
|
|
46
44
|
onunhandledrejection.onUnhandledRejectionIntegration(),
|
|
47
45
|
// Event Info
|
|
48
46
|
contextlines.contextLinesIntegration(),
|
|
49
|
-
index$
|
|
47
|
+
index$2.localVariablesIntegration(),
|
|
50
48
|
context.nodeContextIntegration(),
|
|
51
49
|
childProcess.childProcessIntegration(),
|
|
50
|
+
workerThreads.workerThreadsIntegration(),
|
|
52
51
|
processSession.processSessionIntegration(),
|
|
53
|
-
modules.modulesIntegration()
|
|
52
|
+
modules.modulesIntegration(),
|
|
53
|
+
// Framework-level integrations
|
|
54
|
+
...serverUtils.getErrorIntegrations()
|
|
54
55
|
];
|
|
55
56
|
}
|
|
56
57
|
function getDefaultIntegrationsWithoutPerformance() {
|
|
@@ -59,11 +60,8 @@ function getDefaultIntegrationsWithoutPerformance() {
|
|
|
59
60
|
function getDefaultIntegrations(options) {
|
|
60
61
|
return [
|
|
61
62
|
...getDefaultIntegrationsWithoutPerformance(),
|
|
62
|
-
// We only add
|
|
63
|
-
|
|
64
|
-
// This means that generally request isolation will work (because that is done by httpIntegration)
|
|
65
|
-
// But `transactionName` will not be set automatically
|
|
66
|
-
...core.hasSpansEnabled(options) ? index.getAutoPerformanceIntegrations() : []
|
|
63
|
+
// We only add tracing-only integrations if tracing is enabled
|
|
64
|
+
...core.hasSpansEnabled(options) ? serverUtils.getTracingIntegrations() : []
|
|
67
65
|
];
|
|
68
66
|
}
|
|
69
67
|
function init(options = {}) {
|
|
@@ -97,19 +95,11 @@ function _init(options = {}, getDefaultIntegrationsImpl) {
|
|
|
97
95
|
...options,
|
|
98
96
|
tracesSampleRate: getTracesSampleRate(options.tracesSampleRate)
|
|
99
97
|
};
|
|
100
|
-
|
|
101
|
-
if (useChannelInjection) {
|
|
98
|
+
if ((typeof __SENTRY_CHANNEL_INJECTION__ === "undefined" || __SENTRY_CHANNEL_INJECTION__) && options.enableRuntimeChannelInjection !== false) {
|
|
102
99
|
register.registerDiagnosticsChannelInjection();
|
|
103
100
|
}
|
|
104
101
|
const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(optionsWithResolvedTracing);
|
|
105
102
|
const clientOptions = getClientOptions({ ...options, defaultIntegrations }, getDefaultIntegrationsImpl);
|
|
106
|
-
let asyncLocalStorageLookup;
|
|
107
|
-
if (!clientOptions.enableOpenTelemetrySetup) {
|
|
108
|
-
const asyncLocalStorage = serverUtils.setAsyncLocalStorageAsyncContextStrategy();
|
|
109
|
-
asyncLocalStorageLookup = { asyncLocalStorage };
|
|
110
|
-
} else {
|
|
111
|
-
asyncLocalStorageLookup = opentelemetry.setOpenTelemetryContextAsyncContextStrategy();
|
|
112
|
-
}
|
|
113
103
|
const scope = core.getCurrentScope();
|
|
114
104
|
scope.update(clientOptions.initialScope);
|
|
115
105
|
if (clientOptions.spotlight && !clientOptions.integrations.some(({ name }) => name === spotlight.INTEGRATION_NAME)) {
|
|
@@ -122,7 +112,6 @@ function _init(options = {}, getDefaultIntegrationsImpl) {
|
|
|
122
112
|
const client$1 = new client.NodeClient(clientOptions);
|
|
123
113
|
core.getCurrentScope().setClient(client$1);
|
|
124
114
|
client$1.init();
|
|
125
|
-
client$1.asyncLocalStorageLookup = asyncLocalStorageLookup;
|
|
126
115
|
core.debug.log(`SDK initialized from CommonJS`);
|
|
127
116
|
client$1.startClientReportTracking();
|
|
128
117
|
updateScopeFromEnvVariables();
|
|
@@ -134,9 +123,7 @@ function _init(options = {}, getDefaultIntegrationsImpl) {
|
|
|
134
123
|
if (clientOptions.enableOpenTelemetrySetup) {
|
|
135
124
|
initOtel.initOpenTelemetry(client$1);
|
|
136
125
|
}
|
|
137
|
-
|
|
138
|
-
orchestrion.detectOrchestrionSetup();
|
|
139
|
-
}
|
|
126
|
+
serverUtils.detectOrchestrionSetup();
|
|
140
127
|
return client$1;
|
|
141
128
|
}
|
|
142
129
|
function getClientOptions(options, getDefaultIntegrationsImpl) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/sdk/index.ts"],"sourcesContent":["import type { Integration, Options } from '@sentry/core';\nimport {\n applySdkMetadata,\n consoleSandbox,\n conversationIdIntegration,\n debug,\n envToBool,\n eventFiltersIntegration,\n functionToStringIntegration,\n getCurrentScope,\n getIntegrationsToSetup,\n hasSpansEnabled,\n linkedErrorsIntegration,\n propagationContextFromHeaders,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport { setOpenTelemetryContextAsyncContextStrategy } from '@sentry/opentelemetry';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils';\nimport { isMainThread, parentPort } from 'node:worker_threads';\nimport { detectOrchestrionSetup } from '@sentry/server-utils/orchestrion';\nimport { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { childProcessIntegration } from '../integrations/childProcess';\nimport { consoleIntegration } from '../integrations/console';\nimport { nodeContextIntegration } from '../integrations/context';\nimport { contextLinesIntegration } from '../integrations/contextlines';\nimport { httpIntegration } from '../integrations/http';\nimport { localVariablesIntegration } from '../integrations/local-variables';\nimport { modulesIntegration } from '../integrations/modules';\nimport { nativeNodeFetchIntegration } from '../integrations/node-fetch';\nimport { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception';\nimport { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection';\nimport { processSessionIntegration } from '../integrations/processSession';\nimport { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight';\nimport { systemErrorIntegration } from '../integrations/systemError';\nimport { getAutoPerformanceIntegrations } from '../integrations/tracing';\nimport { makeNodeTransport } from '../transports';\nimport type { NodeClientOptions, NodeOptions } from '../types';\nimport { getEntryPointType } from '../utils/entry-point';\nimport { getSpotlightConfig } from '../utils/spotlight';\nimport { defaultStackParser, getSentryRelease } from './api';\nimport { NodeClient } from './client';\nimport { initOpenTelemetry } from './initOtel';\n\n/**\n * Get the base default integrations shared by all Node SDK default-integration sets.\n */\nfunction getBaseDefaultIntegrations(): Integration[] {\n return [\n // Common\n eventFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n requestDataIntegration(),\n systemErrorIntegration(),\n conversationIdIntegration(),\n // Native Wrappers\n consoleIntegration(),\n httpIntegration(),\n nativeNodeFetchIntegration(),\n // Global Handlers\n onUncaughtExceptionIntegration(),\n onUnhandledRejectionIntegration(),\n // Event Info\n contextLinesIntegration(),\n localVariablesIntegration(),\n nodeContextIntegration(),\n childProcessIntegration(),\n processSessionIntegration(),\n modulesIntegration(),\n ];\n}\n\n/**\n * Get default integrations, excluding performance.\n */\nexport function getDefaultIntegrationsWithoutPerformance(): Integration[] {\n return getBaseDefaultIntegrations();\n}\n\n/** Get the default integrations for the Node SDK. */\nexport function getDefaultIntegrations(options: Options): Integration[] {\n return [\n ...getDefaultIntegrationsWithoutPerformance(),\n // We only add performance integrations if tracing is enabled\n // Note that this means that without tracing enabled, e.g. `expressIntegration()` will not be added\n // This means that generally request isolation will work (because that is done by httpIntegration)\n // But `transactionName` will not be set automatically\n ...(hasSpansEnabled(options) ? getAutoPerformanceIntegrations() : []),\n ];\n}\n\n/**\n * Initialize Sentry for Node.\n */\nexport function init(options: NodeOptions | undefined = {}): NodeClient | undefined {\n return _init(options, getDefaultIntegrations);\n}\n\n/**\n * Initialize Sentry for Node, without any integrations added by default.\n */\nexport function initWithoutDefaultIntegrations(options: NodeOptions | undefined = {}): NodeClient | undefined {\n return _init(options, () => []);\n}\n\n/**\n * Internal initialization function.\n */\nfunction _init(\n options: NodeOptions | undefined = {},\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClient | undefined {\n // Node re-runs `--require` preloads (though not `--import` ones) on the module loader thread it\n // spawns for `Module.register()`, which `init()` itself triggers (channel injection, the ESM\n // loader hook). So a `--require`d instrument file re-enters `init()` there, on a thread that\n // never runs app code. It is recognizable as the only thread without a `parentPort`:\n // user-created workers always have one and are legitimately instrumented.\n if (!isMainThread && !parentPort) {\n return undefined;\n }\n\n if (getEntryPointType() === 'require') {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Initializing the SDK via the Node `--require` flag is no longer supported, because Node re-runs `--require` preloads on its module loader thread. Use `--import` instead: `node --import ./instrument.js app.js`',\n );\n });\n }\n\n applySdkMetadata(options, 'node');\n\n // Enable debug logging before channel-injection registration below, so its failure modes (e.g. no\n // available Node hook API, dep-resolution errors) actually surface. `getClientOptions` resolves\n // `debug` the same way for the client; resolving it here as well keeps the two in agreement.\n if (envToBool(options.debug ?? process.env.SENTRY_DEBUG)) {\n if (DEBUG_BUILD) {\n debug.enable();\n } else {\n // use `console.warn` rather than `debug.warn` since non-debug bundles have all `debug.x` statements stripped\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');\n });\n }\n }\n\n // Resolve the tracing-affecting options (e.g. `SENTRY_TRACES_SAMPLE_RATE`) up front so that both\n // the span-enablement gate below and default-integration selection see the final values. Without\n // this, enabling tracing purely via env would leave `hasSpansEnabled` false at this point and skip\n // the performance integrations. `getClientOptions` resolves the remaining options later.\n const optionsWithResolvedTracing = {\n ...options,\n tracesSampleRate: getTracesSampleRate(options.tracesSampleRate),\n };\n\n // Gate channel-based (orchestrion diagnostics-channel) instrumentation on span recording: the\n // channel integrations only produce spans, so with tracing off there are no subscribers and\n // injecting the module hooks would be pointless work. Install the hooks as early as possible,\n // before the app imports its instrumented modules.\n const useChannelInjection = hasSpansEnabled(optionsWithResolvedTracing);\n if (useChannelInjection) {\n registerDiagnosticsChannelInjection();\n }\n\n // Only use Node SDK defaults if none provided.\n const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(optionsWithResolvedTracing);\n\n const clientOptions = getClientOptions({ ...options, defaultIntegrations }, getDefaultIntegrationsImpl);\n\n // When Sentry does not own an OpenTelemetry tracer provider, scope isolation runs on a pure\n // AsyncLocalStorage strategy instead of the OpenTelemetry context strategy. Instrumentation still\n // emits spans via core `startSpan`; there is just no OTel provider or propagator behind them.\n let asyncLocalStorageLookup: ReturnType<typeof setOpenTelemetryContextAsyncContextStrategy> | undefined;\n if (!clientOptions.enableOpenTelemetrySetup) {\n // The ALS store already is the `{ scope, isolationScope }` object, so no `contextSymbol` is needed\n // to reach it (unlike the OTel context strategy, where it is nested under the OTel context).\n const asyncLocalStorage = setAsyncLocalStorageAsyncContextStrategy();\n asyncLocalStorageLookup = { asyncLocalStorage };\n } else {\n asyncLocalStorageLookup = setOpenTelemetryContextAsyncContextStrategy();\n }\n\n const scope = getCurrentScope();\n scope.update(clientOptions.initialScope);\n\n if (clientOptions.spotlight && !clientOptions.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {\n clientOptions.integrations.push(\n spotlightIntegration({\n sidecarUrl: typeof clientOptions.spotlight === 'string' ? clientOptions.spotlight : undefined,\n }),\n );\n }\n\n const client = new NodeClient(clientOptions);\n // The client is on the current scope, from where it generally is inherited\n getCurrentScope().setClient(client);\n\n client.init();\n client.asyncLocalStorageLookup = asyncLocalStorageLookup;\n\n /*! rollup-include-cjs-only */\n debug.log(`SDK initialized from CommonJS`);\n /*! rollup-include-cjs-only-end */\n /*! rollup-include-esm-only */\n debug.log(`SDK initialized from ESM`);\n /*! rollup-include-esm-only-end */\n\n client.startClientReportTracking();\n\n updateScopeFromEnvVariables();\n\n // Ensure we flush events when vercel functions are ended\n // See: https://vercel.com/docs/functions/functions-api-reference#sigterm-signal\n if (process.env.VERCEL) {\n process.on('SIGTERM', async () => {\n // We have 500ms for processing here, so we try to make sure to have enough time to send the events\n await client.flush(200);\n });\n }\n\n // Add Node SDK specific OpenTelemetry setup. `setupEventContextTrace` reads the active span from the\n // OpenTelemetry context, so it only belongs here: without a Sentry tracer provider a foreign OTel\n // span could otherwise override the Sentry trace on error events.\n if (clientOptions.enableOpenTelemetrySetup) {\n initOpenTelemetry(client);\n }\n\n // Warn about missing or doubled channel injection. Runs after the client\n // is created so the debug logger is enabled and the warning is emitted.\n if (useChannelInjection) {\n detectOrchestrionSetup();\n }\n\n return client;\n}\n\nfunction getClientOptions(\n options: NodeOptions,\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClientOptions {\n const release = getRelease(options.release);\n\n const spotlight = getSpotlightConfig(options.spotlight);\n\n const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);\n const traceLifecycle = getTraceLifecycle(options.traceLifecycle);\n\n const mergedOptions = {\n ...options,\n dsn: options.dsn ?? process.env.SENTRY_DSN,\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT,\n sendClientReports: options.sendClientReports ?? true,\n transport: options.transport ?? makeNodeTransport,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n release,\n tracesSampleRate,\n spotlight,\n traceLifecycle,\n // Most Node-based SDKs default to running without a Sentry OpenTelemetry tracer provider. SDKs\n // that need OTel spans surfaced in Sentry (nextjs, sveltekit) opt back in by passing `true`.\n enableOpenTelemetrySetup: options.enableOpenTelemetrySetup ?? false,\n debug: envToBool(options.debug ?? process.env.SENTRY_DEBUG),\n };\n\n const integrations = options.integrations;\n const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(mergedOptions);\n\n const resolvedIntegrations = getIntegrationsToSetup({\n defaultIntegrations,\n integrations,\n });\n\n return {\n ...mergedOptions,\n integrations: resolvedIntegrations,\n };\n}\n\nfunction getRelease(release: NodeOptions['release']): string | undefined {\n if (release !== undefined) {\n return release;\n }\n\n const detectedRelease = getSentryRelease();\n if (detectedRelease !== undefined) {\n return detectedRelease;\n }\n\n return undefined;\n}\n\nfunction getTracesSampleRate(tracesSampleRate: NodeOptions['tracesSampleRate']): number | undefined {\n if (tracesSampleRate !== undefined) {\n return tracesSampleRate;\n }\n\n const sampleRateFromEnv = process.env.SENTRY_TRACES_SAMPLE_RATE;\n if (!sampleRateFromEnv) {\n return undefined;\n }\n\n const parsed = parseFloat(sampleRateFromEnv);\n return isFinite(parsed) ? parsed : undefined;\n}\n\nfunction getTraceLifecycle(traceLifecycle: NodeOptions['traceLifecycle']): 'stream' | 'static' {\n if (traceLifecycle !== undefined) {\n return traceLifecycle;\n }\n\n const lifecycleFromEnv = process.env.SENTRY_TRACE_LIFECYCLE;\n\n if (lifecycleFromEnv === 'stream' || lifecycleFromEnv === 'static') {\n return lifecycleFromEnv;\n }\n\n return 'stream';\n}\n\n/**\n * Update scope and propagation context based on environmental variables.\n *\n * See https://github.com/getsentry/rfcs/blob/main/text/0071-continue-trace-over-process-boundaries.md\n * for more details.\n */\nfunction updateScopeFromEnvVariables(): void {\n if (envToBool(process.env.SENTRY_USE_ENVIRONMENT) !== false) {\n const sentryTraceEnv = process.env.SENTRY_TRACE;\n const baggageEnv = process.env.SENTRY_BAGGAGE;\n const propagationContext = propagationContextFromHeaders(sentryTraceEnv, baggageEnv);\n getCurrentScope().setPropagationContext(propagationContext);\n }\n}\n"],"names":["eventFiltersIntegration","functionToStringIntegration","linkedErrorsIntegration","requestDataIntegration","systemErrorIntegration","conversationIdIntegration","consoleIntegration","httpIntegration","nativeNodeFetchIntegration","onUncaughtExceptionIntegration","onUnhandledRejectionIntegration","contextLinesIntegration","localVariablesIntegration","nodeContextIntegration","childProcessIntegration","processSessionIntegration","modulesIntegration","hasSpansEnabled","getAutoPerformanceIntegrations","isMainThread","parentPort","getEntryPointType","consoleSandbox","applySdkMetadata","envToBool","DEBUG_BUILD","debug","registerDiagnosticsChannelInjection","setAsyncLocalStorageAsyncContextStrategy","setOpenTelemetryContextAsyncContextStrategy","getCurrentScope","SPOTLIGHT_INTEGRATION_NAME","spotlightIntegration","client","NodeClient","initOpenTelemetry","detectOrchestrionSetup","getSpotlightConfig","makeNodeTransport","stackParserFromStackParserOptions","defaultStackParser","getSentryRelease","propagationContextFromHeaders"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAS,0BAAA,GAA4C;AACnD,EAAA,OAAO;AAAA;AAAA,IAELA,4BAAA,EAAwB;AAAA,IACxBC,gCAAA,EAA4B;AAAA,IAC5BC,4BAAA,EAAwB;AAAA,IACxBC,2BAAA,EAAuB;AAAA,IACvBC,kCAAA,EAAuB;AAAA,IACvBC,8BAAA,EAA0B;AAAA;AAAA,IAE1BC,4BAAA,EAAmB;AAAA,IACnBC,uBAAA,EAAgB;AAAA,IAChBC,kCAAA,EAA2B;AAAA;AAAA,IAE3BC,kDAAA,EAA+B;AAAA,IAC/BC,oDAAA,EAAgC;AAAA;AAAA,IAEhCC,oCAAA,EAAwB;AAAA,IACxBC,iCAAA,EAA0B;AAAA,IAC1BC,8BAAA,EAAuB;AAAA,IACvBC,oCAAA,EAAwB;AAAA,IACxBC,wCAAA,EAA0B;AAAA,IAC1BC,0BAAA;AAAmB,GACrB;AACF;AAKO,SAAS,wCAAA,GAA0D;AACxE,EAAA,OAAO,0BAAA,EAA2B;AACpC;AAGO,SAAS,uBAAuB,OAAA,EAAiC;AACtE,EAAA,OAAO;AAAA,IACL,GA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A,IAAA,gBAAoE,KAAA,QAAA,EAAA;AAC7F,IAAA,uBAAuB;AACrB,EAAA;AAAO,EACT,OAAA,QAAA;AAEA;AAEA,SAAI,2BAAqB,GAAY;AACnC,EAAA,IAAAjB,cAAO,CAAA,OAAA,CAAA,GAAA,CAAA,sBAAA,CAAA,KAAA,KAAA,EAAA;AAAA,IACT,MAAA,cAAA,GAAA,OAAA,CAAA,GAAA,CAAA,YAAA;AAEA,IAAA,MAAO,UAAA,GAAA,OAAA,CAAA,GAAA,CAAA,cAAA;AACT,IAAA,MAAA,kBAAA,GAAAkB,kCAAA,CAAA,cAAA,EAAA,UAAA,CAAA;AAQA,IAAAZ,oBAAS,EAAA,CAAA,qBAAoC,CAAA,kBAAA,CAAA;AAC3C,EAAA;AACE;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/sdk/index.ts"],"sourcesContent":["import type { Integration, Options } from '@sentry/core';\nimport {\n applySdkMetadata,\n consoleSandbox,\n conversationIdIntegration,\n debug,\n envToBool,\n eventFiltersIntegration,\n functionToStringIntegration,\n getCurrentScope,\n getIntegrationsToSetup,\n hasSpansEnabled,\n linkedErrorsIntegration,\n propagationContextFromHeaders,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport { isMainThread, parentPort } from 'node:worker_threads';\nimport { detectOrchestrionSetup, getErrorIntegrations, getTracingIntegrations } from '@sentry/server-utils';\nimport { registerDiagnosticsChannelInjection } from '@sentry/server-runtime-injection/register';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { childProcessIntegration } from '../integrations/childProcess';\nimport { consoleIntegration } from '../integrations/console';\nimport { nodeContextIntegration } from '../integrations/context';\nimport { contextLinesIntegration } from '../integrations/contextlines';\nimport { httpIntegration } from '../integrations/http';\nimport { localVariablesIntegration } from '../integrations/local-variables';\nimport { modulesIntegration } from '../integrations/modules';\nimport { nativeNodeFetchIntegration } from '../integrations/node-fetch';\nimport { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception';\nimport { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection';\nimport { processSessionIntegration } from '../integrations/processSession';\nimport { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight';\nimport { systemErrorIntegration } from '../integrations/systemError';\nimport { workerThreadsIntegration } from '../integrations/workerThreads';\nimport { makeNodeTransport } from '../transports';\nimport type { NodeClientOptions, NodeOptions } from '../types';\nimport { getEntryPointType } from '../utils/entry-point';\nimport { getSpotlightConfig } from '../utils/spotlight';\nimport { defaultStackParser, getSentryRelease } from './api';\nimport { NodeClient } from './client';\nimport { initOpenTelemetry } from './initOtel';\n\n// Treeshakable guard to remove all code related to runtime diagnostics-channel injection. Set to\n// `false` at build time by the Sentry bundler plugins' `bundleSizeOptimizations.excludeChannelInjection`.\ndeclare const __SENTRY_CHANNEL_INJECTION__: boolean | undefined;\n\n/**\n * Get the base default integrations shared by all Node SDK default-integration sets.\n */\nfunction getBaseDefaultIntegrations(): Integration[] {\n return [\n // Common\n eventFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n requestDataIntegration(),\n systemErrorIntegration(),\n conversationIdIntegration(),\n // Native Wrappers\n consoleIntegration(),\n httpIntegration(),\n nativeNodeFetchIntegration(),\n // Global Handlers\n onUncaughtExceptionIntegration(),\n onUnhandledRejectionIntegration(),\n // Event Info\n contextLinesIntegration(),\n localVariablesIntegration(),\n nodeContextIntegration(),\n childProcessIntegration(),\n workerThreadsIntegration(),\n processSessionIntegration(),\n modulesIntegration(),\n // Framework-level integrations\n ...getErrorIntegrations(),\n ];\n}\n\n/**\n * Get default integrations, excluding performance.\n */\nexport function getDefaultIntegrationsWithoutPerformance(): Integration[] {\n return getBaseDefaultIntegrations();\n}\n\n/** Get the default integrations for the Node SDK. */\nexport function getDefaultIntegrations(options: Options): Integration[] {\n return [\n ...getDefaultIntegrationsWithoutPerformance(),\n // We only add tracing-only integrations if tracing is enabled\n ...(hasSpansEnabled(options) ? getTracingIntegrations() : []),\n ];\n}\n\n/**\n * Initialize Sentry for Node.\n */\nexport function init(options: NodeOptions | undefined = {}): NodeClient | undefined {\n return _init(options, getDefaultIntegrations);\n}\n\n/**\n * Initialize Sentry for Node, without any integrations added by default.\n */\nexport function initWithoutDefaultIntegrations(options: NodeOptions | undefined = {}): NodeClient | undefined {\n return _init(options, () => []);\n}\n\n/**\n * Internal initialization function.\n */\nfunction _init(\n options: NodeOptions | undefined = {},\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClient | undefined {\n // Node re-runs `--require` preloads (though not `--import` ones) on the module loader thread it\n // spawns for `Module.register()`, which `init()` itself triggers (channel injection, the ESM\n // loader hook). So a `--require`d instrument file re-enters `init()` there, on a thread that\n // never runs app code. It is recognizable as the only thread without a `parentPort`:\n // user-created workers always have one and are legitimately instrumented.\n if (!isMainThread && !parentPort) {\n return undefined;\n }\n\n if (getEntryPointType() === 'require') {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Initializing the SDK via the Node `--require` flag is no longer supported, because Node re-runs `--require` preloads on its module loader thread. Use `--import` instead: `node --import ./instrument.js app.js`',\n );\n });\n }\n\n applySdkMetadata(options, 'node');\n\n // Enable debug logging before channel-injection registration below, so its failure modes (e.g. no\n // available Node hook API, dep-resolution errors) actually surface. `getClientOptions` resolves\n // `debug` the same way for the client; resolving it here as well keeps the two in agreement.\n if (envToBool(options.debug ?? process.env.SENTRY_DEBUG)) {\n if (DEBUG_BUILD) {\n debug.enable();\n } else {\n // use `console.warn` rather than `debug.warn` since non-debug bundles have all `debug.x` statements stripped\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');\n });\n }\n }\n\n // Resolve the tracing-affecting options (e.g. `SENTRY_TRACES_SAMPLE_RATE`) up front so that\n // default-integration selection sees the final values. Without this, enabling tracing purely via\n // env would leave `hasSpansEnabled` false at this point and skip the performance integrations.\n // `getClientOptions` resolves the remaining options later.\n const optionsWithResolvedTracing = {\n ...options,\n tracesSampleRate: getTracesSampleRate(options.tracesSampleRate),\n };\n\n // Install the channel-based (orchestrion diagnostics-channel) instrumentation hooks by default,\n // independent of tracing — the channel integrations also capture errors, not just spans. Opt out at\n // runtime with `enableRuntimeChannelInjection: false`, or at build time via the bundler plugins'\n // `bundleSizeOptimizations.excludeChannelInjection` (which tree-shakes this whole block away).\n // Install as early as possible, before the app imports its instrumented modules.\n if (\n (typeof __SENTRY_CHANNEL_INJECTION__ === 'undefined' || __SENTRY_CHANNEL_INJECTION__) &&\n options.enableRuntimeChannelInjection !== false\n ) {\n registerDiagnosticsChannelInjection();\n }\n\n // Only use Node SDK defaults if none provided.\n const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(optionsWithResolvedTracing);\n\n const clientOptions = getClientOptions({ ...options, defaultIntegrations }, getDefaultIntegrationsImpl);\n\n const scope = getCurrentScope();\n scope.update(clientOptions.initialScope);\n\n if (clientOptions.spotlight && !clientOptions.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {\n clientOptions.integrations.push(\n spotlightIntegration({\n sidecarUrl: typeof clientOptions.spotlight === 'string' ? clientOptions.spotlight : undefined,\n }),\n );\n }\n\n const client = new NodeClient(clientOptions);\n // The client is on the current scope, from where it generally is inherited\n getCurrentScope().setClient(client);\n\n client.init();\n\n /*! rollup-include-cjs-only */\n debug.log(`SDK initialized from CommonJS`);\n /*! rollup-include-cjs-only-end */\n /*! rollup-include-esm-only */\n debug.log(`SDK initialized from ESM`);\n /*! rollup-include-esm-only-end */\n\n client.startClientReportTracking();\n\n updateScopeFromEnvVariables();\n\n // Ensure we flush events when vercel functions are ended\n // See: https://vercel.com/docs/functions/functions-api-reference#sigterm-signal\n if (process.env.VERCEL) {\n process.on('SIGTERM', async () => {\n // We have 500ms for processing here, so we try to make sure to have enough time to send the events\n await client.flush(200);\n });\n }\n\n // Add Node SDK specific OpenTelemetry setup. `setupEventContextTrace` reads the active span from the\n // OpenTelemetry context, so it only belongs here: without a Sentry tracer provider a foreign OTel\n // span could otherwise override the Sentry trace on error events.\n if (clientOptions.enableOpenTelemetrySetup) {\n initOpenTelemetry(client);\n }\n\n // Warn about missing or doubled channel injection. Runs after the client\n // is created so the debug logger is enabled and the warning is emitted.\n detectOrchestrionSetup();\n\n return client;\n}\n\nfunction getClientOptions(\n options: NodeOptions,\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClientOptions {\n const release = getRelease(options.release);\n\n const spotlight = getSpotlightConfig(options.spotlight);\n\n const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);\n const traceLifecycle = getTraceLifecycle(options.traceLifecycle);\n\n const mergedOptions = {\n ...options,\n dsn: options.dsn ?? process.env.SENTRY_DSN,\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT,\n sendClientReports: options.sendClientReports ?? true,\n transport: options.transport ?? makeNodeTransport,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n release,\n tracesSampleRate,\n spotlight,\n traceLifecycle,\n // Most Node-based SDKs default to running without a Sentry OpenTelemetry tracer provider. SDKs\n // that need OTel spans surfaced in Sentry (nextjs, sveltekit) opt back in by passing `true`.\n enableOpenTelemetrySetup: options.enableOpenTelemetrySetup ?? false,\n debug: envToBool(options.debug ?? process.env.SENTRY_DEBUG),\n };\n\n const integrations = options.integrations;\n const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(mergedOptions);\n\n const resolvedIntegrations = getIntegrationsToSetup({\n defaultIntegrations,\n integrations,\n });\n\n return {\n ...mergedOptions,\n integrations: resolvedIntegrations,\n };\n}\n\nfunction getRelease(release: NodeOptions['release']): string | undefined {\n if (release !== undefined) {\n return release;\n }\n\n const detectedRelease = getSentryRelease();\n if (detectedRelease !== undefined) {\n return detectedRelease;\n }\n\n return undefined;\n}\n\nfunction getTracesSampleRate(tracesSampleRate: NodeOptions['tracesSampleRate']): number | undefined {\n if (tracesSampleRate !== undefined) {\n return tracesSampleRate;\n }\n\n const sampleRateFromEnv = process.env.SENTRY_TRACES_SAMPLE_RATE;\n if (!sampleRateFromEnv) {\n return undefined;\n }\n\n const parsed = parseFloat(sampleRateFromEnv);\n return isFinite(parsed) ? parsed : undefined;\n}\n\nfunction getTraceLifecycle(traceLifecycle: NodeOptions['traceLifecycle']): 'stream' | 'static' {\n if (traceLifecycle !== undefined) {\n return traceLifecycle;\n }\n\n const lifecycleFromEnv = process.env.SENTRY_TRACE_LIFECYCLE;\n\n if (lifecycleFromEnv === 'stream' || lifecycleFromEnv === 'static') {\n return lifecycleFromEnv;\n }\n\n return 'stream';\n}\n\n/**\n * Update scope and propagation context based on environmental variables.\n *\n * See https://github.com/getsentry/rfcs/blob/main/text/0071-continue-trace-over-process-boundaries.md\n * for more details.\n */\nfunction updateScopeFromEnvVariables(): void {\n if (envToBool(process.env.SENTRY_USE_ENVIRONMENT) !== false) {\n const sentryTraceEnv = process.env.SENTRY_TRACE;\n const baggageEnv = process.env.SENTRY_BAGGAGE;\n const propagationContext = propagationContextFromHeaders(sentryTraceEnv, baggageEnv);\n getCurrentScope().setPropagationContext(propagationContext);\n }\n}\n"],"names":["eventFiltersIntegration","functionToStringIntegration","linkedErrorsIntegration","requestDataIntegration","systemErrorIntegration","conversationIdIntegration","consoleIntegration","httpIntegration","nativeNodeFetchIntegration","onUncaughtExceptionIntegration","onUnhandledRejectionIntegration","contextLinesIntegration","localVariablesIntegration","nodeContextIntegration","childProcessIntegration","workerThreadsIntegration","processSessionIntegration","modulesIntegration","getErrorIntegrations","hasSpansEnabled","getTracingIntegrations","isMainThread","parentPort","getEntryPointType","consoleSandbox","applySdkMetadata","envToBool","DEBUG_BUILD","debug","registerDiagnosticsChannelInjection","getCurrentScope","SPOTLIGHT_INTEGRATION_NAME","spotlightIntegration","client","NodeClient","initOpenTelemetry","detectOrchestrionSetup","getSpotlightConfig","makeNodeTransport","stackParserFromStackParserOptions","defaultStackPar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A,gBAAO,KAAA,MAAA,EAAA;AAAA,IACT,OAAA,gBAAA;AAEA,EAAA;AACF,EAAA,MAAA,iBAAA,GAAA,OAAA,CAAA,GAAA,CAAA,yBAAA;AAEA,EAAA,IAAA,CAAA;AACE,IAAA;AACE,EAAA;AAAO,EACT,MAAA,MAAA,GAAA,UAAA,CAAA,iBAAA,CAAA;AAEA,EAAA,OAAM,QAAA,CAAA,MAAA,CAAA,GAAoB,SAAQ,MAAI;AACtC;AACE,SAAA,iBAAO,CAAA,cAAA,EAAA;AAAA,EACT,IAAA,cAAA,KAAA,MAAA,EAAA;AAEA,IAAA,OAAM;AACN,EAAA;AACF,EAAA,MAAA,gBAAA,GAAA,OAAA,CAAA,GAAA,CAAA,sBAAA;AAEA,EAAA,IAAA,qBAA2B,QAAA,IAAA,gBAAoE,KAAA,QAAA,EAAA;AAC7F,IAAA,uBAAuB;AACrB,EAAA;AAAO,EACT,OAAA,QAAA;AAEA;AAEA,SAAI,2BAAqB,GAAY;AACnC,EAAA,IAAAf,cAAO,CAAA,OAAA,CAAA,GAAA,CAAA,sBAAA,CAAA,KAAA,KAAA,EAAA;AAAA,IACT,MAAA,cAAA,GAAA,OAAA,CAAA,GAAA,CAAA,YAAA;AAEA,IAAA,MAAO,UAAA,GAAA,OAAA,CAAA,GAAA,CAAA,cAAA;AACT,IAAA,MAAA,kBAAA,GAAAgB,kCAAA,CAAA,cAAA,EAAA,UAAA,CAAA;AAQA,IAAAZ,oBAAS,EAAA,CAAA,qBAAoC,CAAA,kBAAA,CAAA;AAC3C,EAAA;AACE;;;;;;;"}
|
|
@@ -34,7 +34,7 @@ function makeNodeTransport(options) {
|
|
|
34
34
|
options.proxy || (isHttps ? process.env.https_proxy : void 0) || process.env.http_proxy
|
|
35
35
|
);
|
|
36
36
|
const nativeHttpModule = isHttps ? https : http;
|
|
37
|
-
const keepAlive = options.keepAlive
|
|
37
|
+
const keepAlive = options.keepAlive ?? true;
|
|
38
38
|
const agent = proxy ? new index.HttpsProxyAgent(proxy) : new nativeHttpModule.Agent({ keepAlive, maxSockets: 30, timeout: 2e3 });
|
|
39
39
|
const requestExecutor = createRequestExecutor(options, options.httpModule ?? nativeHttpModule, agent);
|
|
40
40
|
return core.createTransport(options, requestExecutor);
|
|
@@ -53,7 +53,7 @@ function applyNoProxyOption(transportUrlSegments, proxy) {
|
|
|
53
53
|
function createRequestExecutor(options, httpModule, agent) {
|
|
54
54
|
const { hostname, pathname, port, protocol, search } = new URL(options.url);
|
|
55
55
|
return function makeRequest(request) {
|
|
56
|
-
|
|
56
|
+
const sendRequest = (canRetry) => new Promise((resolve, reject) => {
|
|
57
57
|
core.suppressTracing(() => {
|
|
58
58
|
let body = streamFromBody(request.body);
|
|
59
59
|
const headers = { ...options.headers };
|
|
@@ -91,10 +91,17 @@ function createRequestExecutor(options, httpModule, agent) {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
);
|
|
94
|
-
req.on("error",
|
|
94
|
+
req.on("error", (error) => {
|
|
95
|
+
if (canRetry && req.reusedSocket && error.code === "ECONNRESET") {
|
|
96
|
+
resolve(sendRequest(false));
|
|
97
|
+
} else {
|
|
98
|
+
reject(error);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
95
101
|
body.pipe(req);
|
|
96
102
|
});
|
|
97
103
|
});
|
|
104
|
+
return sendRequest(true);
|
|
98
105
|
};
|
|
99
106
|
}
|
|
100
107
|
|