@sentry/node 11.0.0-alpha.0 → 11.0.0-alpha.2
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/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 +53 -53
- 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 +2 -1
- package/build/cjs/integrations/fs/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +2 -8
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/cjs/integrations/http/httpServerIntegration.js.map +1 -1
- package/build/cjs/integrations/http/httpServerSpansIntegration.js +34 -62
- package/build/cjs/integrations/http/httpServerSpansIntegration.js.map +1 -1
- package/build/cjs/integrations/http/index.js +9 -27
- 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 +3 -5
- package/build/cjs/integrations/node-fetch/undici-instrumentation.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/client.js +23 -13
- package/build/cjs/sdk/client.js.map +1 -1
- package/build/cjs/sdk/index.js +19 -34
- package/build/cjs/sdk/index.js.map +1 -1
- package/build/cjs/sdk/initOtel.js +1 -10
- package/build/cjs/sdk/initOtel.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 +6 -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 +2 -1
- package/build/esm/integrations/fs/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +3 -9
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/esm/integrations/http/httpServerIntegration.js.map +1 -1
- package/build/esm/integrations/http/httpServerSpansIntegration.js +36 -64
- package/build/esm/integrations/http/httpServerSpansIntegration.js.map +1 -1
- package/build/esm/integrations/http/index.js +10 -28
- 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 +5 -7
- package/build/esm/integrations/node-fetch/undici-instrumentation.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/client.js +23 -13
- package/build/esm/sdk/client.js.map +1 -1
- package/build/esm/sdk/index.js +14 -29
- package/build/esm/sdk/index.js.map +1 -1
- package/build/esm/sdk/initOtel.js +4 -12
- package/build/esm/sdk/initOtel.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/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 -7
- 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 +6 -61
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/http/httpServerIntegration.d.ts +1 -1
- package/build/types/integrations/http/httpServerSpansIntegration.d.ts +1 -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/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/client.d.ts +2 -0
- package/build/types/sdk/client.d.ts.map +1 -1
- package/build/types/sdk/index.d.ts.map +1 -1
- package/build/types/sdk/initOtel.d.ts +0 -9
- package/build/types/sdk/initOtel.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 +18 -35
- package/build/types/types.d.ts.map +1 -1
- package/package.json +7 -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 -42
- 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 -39
- 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
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
|
|
5
|
+
const serverUtils = require('@sentry/server-utils');
|
|
8
6
|
const register = require('@sentry/server-utils/orchestrion/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.skipOpenTelemetrySetup) {
|
|
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();
|
|
@@ -131,14 +120,10 @@ function _init(options = {}, getDefaultIntegrationsImpl) {
|
|
|
131
120
|
await client$1.flush(200);
|
|
132
121
|
});
|
|
133
122
|
}
|
|
134
|
-
|
|
135
|
-
if (!clientOptions.skipOpenTelemetrySetup) {
|
|
136
|
-
opentelemetry.setupEventContextTrace(client$1);
|
|
123
|
+
if (clientOptions.enableOpenTelemetrySetup) {
|
|
137
124
|
initOtel.initOpenTelemetry(client$1);
|
|
138
125
|
}
|
|
139
|
-
|
|
140
|
-
orchestrion.detectOrchestrionSetup();
|
|
141
|
-
}
|
|
126
|
+
serverUtils.detectOrchestrionSetup();
|
|
142
127
|
return client$1;
|
|
143
128
|
}
|
|
144
129
|
function getClientOptions(options, getDefaultIntegrationsImpl) {
|
|
@@ -158,8 +143,8 @@ function getClientOptions(options, getDefaultIntegrationsImpl) {
|
|
|
158
143
|
spotlight,
|
|
159
144
|
traceLifecycle,
|
|
160
145
|
// Most Node-based SDKs default to running without a Sentry OpenTelemetry tracer provider. SDKs
|
|
161
|
-
// that need OTel spans surfaced in Sentry (nextjs, sveltekit) opt back in by passing `
|
|
162
|
-
|
|
146
|
+
// that need OTel spans surfaced in Sentry (nextjs, sveltekit) opt back in by passing `true`.
|
|
147
|
+
enableOpenTelemetrySetup: options.enableOpenTelemetrySetup ?? false,
|
|
163
148
|
debug: core.envToBool(options.debug ?? process.env.SENTRY_DEBUG)
|
|
164
149
|
};
|
|
165
150
|
const integrations = options.integrations;
|
|
@@ -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, setupEventContextTrace } 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, setupSpanDataBackfill } 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.skipOpenTelemetrySetup) {\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 // Channel-based instrumentation emits spans via core `startSpan` in every mode, so always backfill\n // the Sentry-convention span data (e.g. `sentry.op`) the OTel provider pipeline would otherwise\n // derive. It is idempotent, so it is a no-op for spans the provider already enriches.\n setupSpanDataBackfill(client);\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.skipOpenTelemetrySetup) {\n setupEventContextTrace(client);\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 `false`.\n skipOpenTelemetrySetup: options.skipOpenTelemetrySetup ?? true,\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","setupSpanDataBackfill","setupEventContextTrace","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,IACxB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A,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,IAAAnB,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,GAAAoB,kCAAA,CAAA,cAAA,EAAA,UAAA,CAAA;AAQA,IAAAd,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-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 { 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","defaultStackParser","getSentryRelease","propagationContextFromHeaders"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,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,qBAAA,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,sCAAA,EAAyB;AAAA,IACzBC,wCAAA,EAA0B;AAAA,IAC1BC,0BAAA,EAAmB;AAAA;AAAA,IAEnB,GAAGC,gCAAA;AAAqB,GAC1B;AACF;AAKO,SAAS,wCAAA,GAA0D;AACxE,EAAA,OAAO,0BAAA,EAA2B;AACpC;AAGO,SAAS,uBAAuB,OAAA,EAAiC;AACtE,EAAA,OAAO;AAAA,IACL,GAAG,wCAAA,EAAyC;AAAA;AAAA,IAE5C,GAAIC,oBAAA,CAAgB,OAAO,CAAA,GAAIC,kCAAA,KAA2B;AAAC,GAC7D;AACF;AAKO,SAAS,IAAA,CA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C,EAAA;AACE;;;;;;;"}
|
|
@@ -15,7 +15,7 @@ function registerGlobalTracerProvider(provider) {
|
|
|
15
15
|
const registry = otelGlobal[OTEL_API_GLOBAL_KEY];
|
|
16
16
|
if (registry && !registry.trace) {
|
|
17
17
|
debugBuild.DEBUG_BUILD && core.debug.warn(
|
|
18
|
-
"Replaced a pre-existing OpenTelemetry API registry that was created by a different @opentelemetry/api version and would have blocked tracing. If you want to manage OpenTelemetry yourself, set `
|
|
18
|
+
"Replaced a pre-existing OpenTelemetry API registry that was created by a different @opentelemetry/api version and would have blocked tracing. If you want to manage OpenTelemetry yourself, set `enableOpenTelemetrySetup: false` in `Sentry.init()`."
|
|
19
19
|
);
|
|
20
20
|
otelGlobal[OTEL_API_GLOBAL_KEY] = void 0;
|
|
21
21
|
if (!api.trace.setGlobalTracerProvider(provider)) {
|
|
@@ -37,14 +37,6 @@ function initOpenTelemetry(client) {
|
|
|
37
37
|
const provider = setupOtel();
|
|
38
38
|
client.traceProvider = provider;
|
|
39
39
|
}
|
|
40
|
-
function setupSpanDataBackfill(client) {
|
|
41
|
-
client.on("spanEnd", (span) => {
|
|
42
|
-
opentelemetry.applyOtelSpanData(span, { finalizeStatus: true });
|
|
43
|
-
});
|
|
44
|
-
if (core.hasSpanStreamingEnabled(client)) {
|
|
45
|
-
client.on("preprocessSpan", opentelemetry.backfillStreamedSpanDataFromOtel);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
40
|
function setupOtel() {
|
|
49
41
|
const provider = new opentelemetry.SentryTracerProvider();
|
|
50
42
|
if (!registerGlobalTracerProvider(provider)) {
|
|
@@ -59,5 +51,4 @@ function setupOtel() {
|
|
|
59
51
|
|
|
60
52
|
exports.initOpenTelemetry = initOpenTelemetry;
|
|
61
53
|
exports.setupOtel = setupOtel;
|
|
62
|
-
exports.setupSpanDataBackfill = setupSpanDataBackfill;
|
|
63
54
|
//# sourceMappingURL=initOtel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initOtel.js","sources":["../../../src/sdk/initOtel.ts"],"sourcesContent":["import type { TracerProvider } from '@opentelemetry/api';\nimport { propagation, trace } from '@opentelemetry/api';\nimport { debug as coreDebug
|
|
1
|
+
{"version":3,"file":"initOtel.js","sources":["../../../src/sdk/initOtel.ts"],"sourcesContent":["import type { TracerProvider } from '@opentelemetry/api';\nimport { propagation, trace } from '@opentelemetry/api';\nimport { debug as coreDebug } from '@sentry/core';\nimport { setupOpenTelemetryLogger } from '../otel/logger';\nimport type { NodeClient } from './client';\nimport { SentryPropagator, SentryTracerProvider } from '@sentry/opentelemetry';\nimport { DEBUG_BUILD } from '../debug-build';\n\n// The global registry of @opentelemetry/api 1.x, shared across all copies of the package\nconst OTEL_API_GLOBAL_KEY = Symbol.for('opentelemetry.js.api.1');\n\n/**\n * Registers the given tracer provider as the global tracer provider, recreating the OpenTelemetry\n * API registry when it pre-exists with a different `@opentelemetry/api` version.\n *\n * Some host runtimes (e.g. Neon Functions) pre-create the registry with their own API version.\n * `registerGlobal` requires an exact version match, so every registration through the SDK's copy\n * of `@opentelemetry/api` is rejected and tracing is silently disabled\n * (https://github.com/getsentry/sentry-javascript/issues/22338). This case is identified by a\n * failed registration with an empty `trace` slot: `registerGlobal` checks the slot before the\n * version, so an empty slot means the version gate rejected us and recreating the registry\n * clobbers no other tracer provider. If the slot is occupied (another provider registered first,\n * e.g. a second `Sentry.init()` call), the registry is left untouched and registration fails.\n *\n * Slots Sentry does not claim itself (e.g. `diag`, `metrics`) are carried over into the recreated\n * registry: reads resolve via a semver-compatibility check rather than the exact-match write gate,\n * so they keep working for the copy that registered them. `propagation` and `context` are not\n * carried over because Sentry registers its own right after this.\n */\nfunction registerGlobalTracerProvider(provider: TracerProvider): boolean {\n if (trace.setGlobalTracerProvider(provider)) {\n return true;\n }\n\n // @opentelemetry/api stores the registry under a `Symbol.for` key that no public type\n // describes, so `typeof globalThis` can only be narrowed to it by casting through `unknown`.\n const otelGlobal = globalThis as unknown as Record<symbol, Record<string, unknown> | undefined>;\n const registry = otelGlobal[OTEL_API_GLOBAL_KEY];\n if (registry && !registry.trace) {\n DEBUG_BUILD &&\n coreDebug.warn(\n 'Replaced a pre-existing OpenTelemetry API registry that was created by a different @opentelemetry/api version and would have blocked tracing. If you want to manage OpenTelemetry yourself, set `enableOpenTelemetrySetup: false` in `Sentry.init()`.',\n );\n otelGlobal[OTEL_API_GLOBAL_KEY] = undefined;\n\n if (!trace.setGlobalTracerProvider(provider)) {\n return false;\n }\n\n // The cast is needed because TS still has the slot narrowed to `undefined` from the reset\n // above and cannot know the registration call just recreated the registry.\n const recreatedRegistry = otelGlobal[OTEL_API_GLOBAL_KEY] as Record<string, unknown> | undefined;\n if (recreatedRegistry) {\n const { propagation: _propagation, context: _context, ...carriedOverSlots } = registry;\n otelGlobal[OTEL_API_GLOBAL_KEY] = { ...carriedOverSlots, ...recreatedRegistry };\n }\n\n return true;\n }\n\n return false;\n}\n\n/**\n * Initialize OpenTelemetry for Node.\n */\nexport function initOpenTelemetry(client: NodeClient): void {\n if (client.getOptions().debug) {\n setupOpenTelemetryLogger();\n }\n\n const provider = setupOtel();\n client.traceProvider = provider;\n}\n\n/** Just exported for tests. */\nexport function setupOtel(): SentryTracerProvider | undefined {\n const provider = new SentryTracerProvider();\n\n if (!registerGlobalTracerProvider(provider)) {\n DEBUG_BUILD &&\n coreDebug.warn(\n 'Could not register SentryTracerProvider because another OpenTelemetry tracer provider is already registered.',\n );\n return undefined;\n }\n\n propagation.setGlobalPropagator(new SentryPropagator());\n\n return provider;\n}\n"],"names":["trace","DEBUG_BUILD","coreDebug","setupOpenTelemetryLogger","SentryTracerProvider","propagation","SentryPropagator"],"mappings":";;;;;;;;AASA,MAAM,mBAAA,mBAAsB,MAAA,CAAO,GAAA,CAAI,wBAAwB,CAAA;AAoB/D,SAAS,6BAA6B,QAAA,EAAmC;AACvE,EAAA,IAAIA,SAAA,CAAM,uBAAA,CAAwB,QAAQ,CAAA,EAAG;AAC3C,IAAA,O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,CAAoB,IAAIC,8BAAA,EAAkB,CAAA;AAEtD,EAAA,OAAO,QAAA;AACT;;;;;"}
|
|
@@ -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
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sources":["../../../src/transports/http.ts"],"sourcesContent":["import * as http from 'node:http';\nimport * as https from 'node:https';\nimport { Readable } from 'node:stream';\nimport { createGzip } from 'node:zlib';\nimport type {\n BaseTransportOptions,\n Transport,\n TransportMakeRequestResponse,\n TransportRequest,\n TransportRequestExecutor,\n} from '@sentry/core';\nimport { consoleSandbox, createTransport, suppressTracing } from '@sentry/core';\nimport { HttpsProxyAgent } from '../proxy';\nimport type { HTTPModule } from './http-module';\n\nexport interface NodeTransportOptions extends BaseTransportOptions {\n /** Set a proxy that should be used for outbound requests. */\n proxy?: string;\n /** HTTPS proxy CA certificates */\n caCerts?: string | Buffer | Array<string | Buffer>;\n /** Custom HTTP module. Defaults to the native 'http' and 'https' modules. */\n httpModule?: HTTPModule;\n /** Allow overriding connection keepAlive, defaults to false */\n keepAlive?: boolean;\n}\n\n// Estimated maximum size for reasonable standalone event\nconst GZIP_THRESHOLD = 1024 * 32;\n\n/**\n * Gets a stream from a Uint8Array or string\n * Readable.from is ideal but was added in node.js v12.3.0 and v10.17.0\n */\nfunction streamFromBody(body: Uint8Array | string): Readable {\n return new Readable({\n read() {\n this.push(body);\n this.push(null);\n },\n });\n}\n\n/**\n * Creates a Transport that uses native the native 'http' and 'https' modules to send events to Sentry.\n */\nexport function makeNodeTransport(options: NodeTransportOptions): Transport {\n let urlSegments: URL;\n\n try {\n urlSegments = new URL(options.url);\n } catch {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.',\n );\n });\n return createTransport(options, () => Promise.resolve({}));\n }\n\n const isHttps = urlSegments.protocol === 'https:';\n\n // Proxy prioritization: http => `options.proxy` | `process.env.http_proxy`\n // Proxy prioritization: https => `options.proxy` | `process.env.https_proxy` | `process.env.http_proxy`\n const proxy = applyNoProxyOption(\n urlSegments,\n options.proxy || (isHttps ? process.env.https_proxy : undefined) || process.env.http_proxy,\n );\n\n const nativeHttpModule = isHttps ? https : http;\n const keepAlive = options.keepAlive === undefined ? false : options.keepAlive;\n\n // TODO(v11): Evaluate if we can set keepAlive to true. This would involve testing for memory leaks in older node\n // versions(>= 8) as they had memory leaks when using it: #2555\n const agent = proxy\n ? (new HttpsProxyAgent(proxy) as http.Agent)\n : new nativeHttpModule.Agent({ keepAlive, maxSockets: 30, timeout: 2000 });\n\n const requestExecutor = createRequestExecutor(options, options.httpModule ?? nativeHttpModule, agent);\n return createTransport(options, requestExecutor);\n}\n\n/**\n * Honors the `no_proxy` env variable with the highest priority to allow for hosts exclusion.\n *\n * @param transportUrl The URL the transport intends to send events to.\n * @param proxy The client configured proxy.\n * @returns A proxy the transport should use.\n */\nfunction applyNoProxyOption(transportUrlSegments: URL, proxy: string | undefined): string | undefined {\n const { no_proxy } = process.env;\n\n const urlIsExemptFromProxy = no_proxy\n ?.split(',')\n .some(\n exemption => transportUrlSegments.host.endsWith(exemption) || transportUrlSegments.hostname.endsWith(exemption),\n );\n\n if (urlIsExemptFromProxy) {\n return undefined;\n } else {\n return proxy;\n }\n}\n\n/**\n * Creates a RequestExecutor to be used with `createTransport`.\n */\nfunction createRequestExecutor(\n options: NodeTransportOptions,\n httpModule: HTTPModule,\n agent: http.Agent,\n): TransportRequestExecutor {\n const { hostname, pathname, port, protocol, search } = new URL(options.url);\n return function makeRequest(request: TransportRequest): Promise<TransportMakeRequestResponse> {\n return new Promise((resolve, reject) => {\n // This ensures we do not generate any spans in OpenTelemetry for the transport\n suppressTracing(() => {\n let body = streamFromBody(request.body);\n\n const headers: Record<string, string> = { ...options.headers };\n\n if (request.body.length > GZIP_THRESHOLD) {\n headers['content-encoding'] = 'gzip';\n body = body.pipe(createGzip());\n }\n\n const hostnameIsIPv6 = hostname.startsWith('[');\n\n const req = httpModule.request(\n {\n method: 'POST',\n agent,\n headers,\n // Remove \"[\" and \"]\" from IPv6 hostnames\n hostname: hostnameIsIPv6 ? hostname.slice(1, -1) : hostname,\n path: `${pathname}${search}`,\n port,\n protocol,\n ca: options.caCerts,\n },\n res => {\n res.on('data', () => {\n // Drain socket\n });\n\n res.on('end', () => {\n // Drain socket\n });\n\n res.setEncoding('utf8');\n\n // \"Key-value pairs of header names and values. Header names are lower-cased.\"\n // https://nodejs.org/api/http.html#http_message_headers\n const retryAfterHeader = res.headers['retry-after'] ?? null;\n const rateLimitsHeader = res.headers['x-sentry-rate-limits'] ?? null;\n\n resolve({\n statusCode: res.statusCode,\n headers: {\n 'retry-after': retryAfterHeader,\n 'x-sentry-rate-limits': Array.isArray(rateLimitsHeader)\n ? rateLimitsHeader[0] || null\n : rateLimitsHeader,\n },\n });\n },\n );\n\n req.on('error', reject);\n body.pipe(req);\n });\n });\n };\n}\n"],"names":["Readable","consoleSandbox","createTransport","HttpsProxyAgent","suppressTracing","createGzip"],"mappings":";;;;;;;;;AA2BA,MAAM,iBAAiB,IAAA,GAAO,EAAA;AAM9B,SAAS,eAAe,IAAA,EAAqC;AAC3D,EAAA,OAAO,IAAIA,oBAAA,CAAS;AAAA,IAClB,IAAA,GAAO;AACL,MAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AACd,MAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AAAA,IAChB;AAAA,GACD,CAAA;AACH;AAKO,SAAS,kBAAkB,OAAA,EAA0C;AAC1E,EAAA,IAAI,WAAA;AAEJ,EAAA,IAAI;AACF,IAAA,WAAA,GAAc,IAAI,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAA;AAAA,EACnC,CAAA,CAAA,MAAQ;AACN,IAAAC,mBAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AACD,IAAA,OAAOC,qBAAgB,OAAA,EAAS,MAAM,QAAQ,OAAA,CAAQ,EAAE,CAAC,CAAA;AAAA,EAC3D;AAEA,EAAA,MAAM,OAAA,GAAU,YAAY,QAAA,KAAa,QAAA;AAIzC,EAAA,MAAM,KAA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,OAAA,CAAQ,aAAa,CAAA,IAAK,IAAA;AACvD,YAAA,MAAM,gBAAA,GAAmB,GAAA,CAAI,OAAA,CAAQ,sBAAsB,CAAA,IAAK,IAAA;AAEhE,YAAA,OAAA,CAAQ;AAAA,cACN,YAAY,GAAA,CAAI,UAAA;AAAA,cAChB,OAAA,EAAS;AAAA,gBACP,aAAA,EAAe,gBAAA;AAAA,gBACf,sBAAA,EAAwB,MAAM,OAAA,CAAQ,gBAAgB,IAClD,gBAAA,CAAiB,CAAC,KAAK,IAAA,GACvB;AAAA;AACN,aACD,CAAA;AAAA,UACH;AAAA,SACF;AAEA,QAAA,GAAA,CAAI,EAAA,CAAG,SAAS,MAAM,CAAA;AACtB,QAAA,IAAA,CAAK,KAAK,GAAG,CAAA;AAAA,MACf,CAAC,CAAA;AAAA,IACH,CAAC,CAAA;AAAA,EACH,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"http.js","sources":["../../../src/transports/http.ts"],"sourcesContent":["import * as http from 'node:http';\nimport * as https from 'node:https';\nimport { Readable } from 'node:stream';\nimport { createGzip } from 'node:zlib';\nimport type {\n BaseTransportOptions,\n Transport,\n TransportMakeRequestResponse,\n TransportRequest,\n TransportRequestExecutor,\n} from '@sentry/core';\nimport { consoleSandbox, createTransport, suppressTracing } from '@sentry/core';\nimport { HttpsProxyAgent } from '../proxy';\nimport type { HTTPModule } from './http-module';\n\nexport interface NodeTransportOptions extends BaseTransportOptions {\n /** Set a proxy that should be used for outbound requests. */\n proxy?: string;\n /** HTTPS proxy CA certificates */\n caCerts?: string | Buffer | Array<string | Buffer>;\n /** Custom HTTP module. Defaults to the native 'http' and 'https' modules. */\n httpModule?: HTTPModule;\n /** Allow overriding connection keepAlive, defaults to true */\n keepAlive?: boolean;\n}\n\n// Estimated maximum size for reasonable standalone event\nconst GZIP_THRESHOLD = 1024 * 32;\n\n/**\n * Gets a stream from a Uint8Array or string\n * Readable.from is ideal but was added in node.js v12.3.0 and v10.17.0\n */\nfunction streamFromBody(body: Uint8Array | string): Readable {\n return new Readable({\n read() {\n this.push(body);\n this.push(null);\n },\n });\n}\n\n/**\n * Creates a Transport that uses native the native 'http' and 'https' modules to send events to Sentry.\n */\nexport function makeNodeTransport(options: NodeTransportOptions): Transport {\n let urlSegments: URL;\n\n try {\n urlSegments = new URL(options.url);\n } catch {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.',\n );\n });\n return createTransport(options, () => Promise.resolve({}));\n }\n\n const isHttps = urlSegments.protocol === 'https:';\n\n // Proxy prioritization: http => `options.proxy` | `process.env.http_proxy`\n // Proxy prioritization: https => `options.proxy` | `process.env.https_proxy` | `process.env.http_proxy`\n const proxy = applyNoProxyOption(\n urlSegments,\n options.proxy || (isHttps ? process.env.https_proxy : undefined) || process.env.http_proxy,\n );\n\n const nativeHttpModule = isHttps ? https : http;\n const keepAlive = options.keepAlive ?? true;\n const agent = proxy\n ? (new HttpsProxyAgent(proxy) as http.Agent)\n : new nativeHttpModule.Agent({ keepAlive, maxSockets: 30, timeout: 2000 });\n\n const requestExecutor = createRequestExecutor(options, options.httpModule ?? nativeHttpModule, agent);\n return createTransport(options, requestExecutor);\n}\n\n/**\n * Honors the `no_proxy` env variable with the highest priority to allow for hosts exclusion.\n *\n * @param transportUrl The URL the transport intends to send events to.\n * @param proxy The client configured proxy.\n * @returns A proxy the transport should use.\n */\nfunction applyNoProxyOption(transportUrlSegments: URL, proxy: string | undefined): string | undefined {\n const { no_proxy } = process.env;\n\n const urlIsExemptFromProxy = no_proxy\n ?.split(',')\n .some(\n exemption => transportUrlSegments.host.endsWith(exemption) || transportUrlSegments.hostname.endsWith(exemption),\n );\n\n if (urlIsExemptFromProxy) {\n return undefined;\n } else {\n return proxy;\n }\n}\n\n/**\n * Creates a RequestExecutor to be used with `createTransport`.\n */\nfunction createRequestExecutor(\n options: NodeTransportOptions,\n httpModule: HTTPModule,\n agent: http.Agent,\n): TransportRequestExecutor {\n const { hostname, pathname, port, protocol, search } = new URL(options.url);\n return function makeRequest(request: TransportRequest): Promise<TransportMakeRequestResponse> {\n const sendRequest = (canRetry: boolean): Promise<TransportMakeRequestResponse> =>\n new Promise((resolve, reject) => {\n // This ensures we do not generate any spans in OpenTelemetry for the transport\n suppressTracing(() => {\n // Recreate the body on each attempt so a retry is not piping a consumed stream.\n let body = streamFromBody(request.body);\n\n const headers: Record<string, string> = { ...options.headers };\n\n if (request.body.length > GZIP_THRESHOLD) {\n headers['content-encoding'] = 'gzip';\n body = body.pipe(createGzip());\n }\n\n const hostnameIsIPv6 = hostname.startsWith('[');\n\n const req = httpModule.request(\n {\n method: 'POST',\n agent,\n headers,\n // Remove \"[\" and \"]\" from IPv6 hostnames\n hostname: hostnameIsIPv6 ? hostname.slice(1, -1) : hostname,\n path: `${pathname}${search}`,\n port,\n protocol,\n ca: options.caCerts,\n },\n res => {\n res.on('data', () => {\n // Drain socket\n });\n\n res.on('end', () => {\n // Drain socket\n });\n\n res.setEncoding('utf8');\n\n // \"Key-value pairs of header names and values. Header names are lower-cased.\"\n // https://nodejs.org/api/http.html#http_message_headers\n const retryAfterHeader = res.headers['retry-after'] ?? null;\n const rateLimitsHeader = res.headers['x-sentry-rate-limits'] ?? null;\n\n resolve({\n statusCode: res.statusCode,\n headers: {\n 'retry-after': retryAfterHeader,\n 'x-sentry-rate-limits': Array.isArray(rateLimitsHeader)\n ? rateLimitsHeader[0] || null\n : rateLimitsHeader,\n },\n });\n },\n );\n\n req.on('error', error => {\n // Keep-alive sockets can go stale while a serverless isolate is frozen.\n // Node recommends a single retry when the reused socket resets.\n if (canRetry && req.reusedSocket && (error as NodeJS.ErrnoException).code === 'ECONNRESET') {\n resolve(sendRequest(false));\n } else {\n reject(error);\n }\n });\n body.pipe(req);\n });\n });\n\n return sendRequest(true);\n };\n}\n"],"names":["Readable","consoleSandbox","createTransport","HttpsProxyAgent","suppressTracing","createGzip"],"mappings":";;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,YAAA,OAAA,CAAQ,WAAA,CAAY,KAAK,CAAC,CAAA;AAAA,UAC5B,CAAA,MAAO;AACL,YAAA,MAAA,CAAO,KAAK,CAAA;AAAA,UACd;AAAA,QACF,CAAC,CAAA;AACD,QAAA,IAAA,CAAK,KAAK,GAAG,CAAA;AAAA,MACf,CAAC,CAAA;AAAA,IACH,CAAC,CAAA;AAEH,IAAA,OAAO,YAAY,IAAI,CAAA;AAAA,EACzB,CAAA;AACF;;;;"}
|
|
@@ -148,7 +148,7 @@ function getBreadcrumbData(request) {
|
|
|
148
148
|
return {
|
|
149
149
|
url: core.getSanitizedUrlString(parsedUrl),
|
|
150
150
|
// eslint-disable-next-line typescript/no-deprecated
|
|
151
|
-
[attributes.
|
|
151
|
+
[attributes.HTTP_REQUEST_METHOD]: request.method || "GET",
|
|
152
152
|
[attributes.URL_QUERY]: core.filterCollectedUrlQuery(core.getUrlQuery(parsedUrl.search)),
|
|
153
153
|
[attributes.URL_FRAGMENT]: core.getUrlFragment(parsedUrl.hash)
|
|
154
154
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outgoingFetchRequest.js","sources":["../../../src/utils/outgoingFetchRequest.ts"],"sourcesContent":["import { HTTP_METHOD, URL_FRAGMENT, URL_QUERY } from '@sentry/conventions/attributes';\nimport type { LRUMap, SanitizedRequestData, Span } from '@sentry/core';\nimport {\n filterCollectedUrlQuery,\n addBreadcrumb,\n getActiveSpan,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getSanitizedUrlString,\n getTraceData,\n getUrlFragment,\n getUrlQuery,\n parseUrl,\n shouldPropagateTraceForUrl,\n mergeBaggageHeaders,\n spanIsIgnored,\n withActiveSpan,\n} from '@sentry/core';\nimport type { UndiciRequest, UndiciResponse } from '../integrations/node-fetch/types';\nimport { debug } from '@sentry/core';\nconst SENTRY_TRACE_HEADER = 'sentry-trace';\nconst SENTRY_BAGGAGE_HEADER = 'baggage';\nconst W3C_TRACEPARENT_HEADER = 'traceparent';\n/**\n * Add trace propagation headers to an outgoing fetch/undici request.\n *\n * Checks if the request URL matches trace propagation targets,\n * then injects sentry-trace, traceparent, and baggage headers.\n *\n * When a `span` is passed (the outgoing `http.client` span), its trace data is propagated so downstream\n * services are parented to that span. Without a span, the active scope's trace data is used.\n *\n * Existing trace headers (e.g. set manually by the user via `getTraceData()`) always take precedence and\n * are de-duplicated rather than overwritten, so we never emit two `sentry-trace`/`baggage` entries.\n */\n// eslint-disable-next-line complexity\nexport function addTracePropagationHeadersToFetchRequest(\n request: UndiciRequest,\n propagationDecisionMap: LRUMap<string, boolean>,\n span?: Span,\n): void {\n const url = getAbsoluteUrl(request.origin, request.path);\n\n // Manually add the trace headers, if it applies\n // Note: We do not use `propagation.inject()` here, because our propagator relies on an active span\n // Which we do not have in this case\n // The propagator _may_ overwrite this, but this should be fine as it is the same data\n const { tracePropagationTargets, propagateTraceparent } = getClient()?.getOptions() || {};\n\n if (!shouldPropagateTraceForUrl(url, tracePropagationTargets, propagationDecisionMap)) {\n return;\n }\n\n // An ignored child must not become the propagation parent because no span will be emitted for it.\n // Otherwise, make the span active so the propagated headers reference it instead of its parent.\n const spanForTraceHeaders = span && spanIsIgnored(span) && getActiveSpan() ? undefined : span;\n const addedHeaders = spanForTraceHeaders\n ? withActiveSpan(spanForTraceHeaders, () => getTraceData({ propagateTraceparent }))\n : getTraceData({ propagateTraceparent });\n\n if (!addedHeaders) {\n return;\n }\n\n const { 'sentry-trace': sentryTrace, baggage, traceparent } = addedHeaders;\n\n // Undici can expose headers either as a raw string (v5-style) or as a flat array of pairs (v6-style).\n // In the array form, even indices are header names and odd indices are values; in undici v6 a value\n // may be `string | string[]` when a header has multiple values. The helpers below (_deduplicateArrayHeader,\n // push, etc.) expect each value slot to be a single string, so we normalize array headers first.\n const requestHeaders: string[] = Array.isArray(request.headers)\n ? normalizeUndiciHeaderPairs(request.headers)\n : stringToArrayHeaders(request.headers);\n\n // OTel's UndiciInstrumentation calls propagation.inject() which unconditionally\n // appends headers to the request. When the user also sets headers via getTraceData(),\n // this results in duplicate sentry-trace and baggage (and optionally traceparent) entries.\n // We clean these up before applying our own logic.\n _deduplicateArrayHeader(requestHeaders, SENTRY_TRACE_HEADER);\n _deduplicateArrayHeader(requestHeaders, SENTRY_BAGGAGE_HEADER);\n if (propagateTraceparent) {\n _deduplicateArrayHeader(requestHeaders, W3C_TRACEPARENT_HEADER);\n }\n\n // We do not want to overwrite existing headers here\n // If the core UndiciInstrumentation is registered, it will already have set the headers\n // We do not want to add any then\n const hasExistingSentryTraceHeader = _findExistingHeaderIndex(requestHeaders, SENTRY_TRACE_HEADER) !== -1;\n\n // We do not want to set any headers if we already have an existing sentry-trace header.\n // sentry-trace is still the source of truth, otherwise we risk mixing up baggage and sentry-trace values.\n if (!hasExistingSentryTraceHeader) {\n if (sentryTrace) {\n requestHeaders.push(SENTRY_TRACE_HEADER, sentryTrace);\n }\n\n if (traceparent && _findExistingHeaderIndex(requestHeaders, 'traceparent') === -1) {\n requestHeaders.push('traceparent', traceparent);\n }\n\n // For baggage, we make sure to merge this into a possibly existing header\n const existingBaggageIndex = _findExistingHeaderIndex(requestHeaders, SENTRY_BAGGAGE_HEADER);\n if (baggage && existingBaggageIndex === -1) {\n requestHeaders.push(SENTRY_BAGGAGE_HEADER, baggage);\n } else if (baggage) {\n // headers in format [key_0, value_0, key_1, value_1, ...], hence the +1 here\n const existingBaggageValue = requestHeaders[existingBaggageIndex + 1];\n const merged = mergeBaggageHeaders(existingBaggageValue, baggage);\n if (merged) {\n requestHeaders[existingBaggageIndex + 1] = merged;\n }\n }\n }\n\n if (Array.isArray(request.headers)) {\n // Replace contents in place so we keep the same array reference undici/fetch still holds.\n // `requestHeaders` is already normalized (string pairs only); splice writes them back.\n request.headers.splice(0, request.headers.length, ...requestHeaders);\n } else {\n request.headers = arrayToStringHeaders(requestHeaders);\n }\n}\n\n/**\n * Convert undici’s header array into `[name, value, name, value, ...]` where every value is a string.\n *\n * Undici v6 uses this shape: `[k1, v1, k2, v2, ...]`. Types allow each `v` to be `string | string[]` when\n * that header has multiple values. Sentry’s dedupe/merge helpers expect one string per value slot, so\n * multi-value arrays are joined with `', '`. Missing value slots become `''`.\n */\nfunction normalizeUndiciHeaderPairs(headers: (string | string[])[]): string[] {\n const out: string[] = [];\n for (let i = 0; i < headers.length; i++) {\n const entry = headers[i];\n if (i % 2 === 0) {\n // Header name (should always be a string; coerce defensively).\n out.push(typeof entry === 'string' ? entry : String(entry));\n } else {\n // Header value: flatten `string[]` to a single string for downstream string-only helpers.\n out.push(Array.isArray(entry) ? entry.join(', ') : (entry ?? ''));\n }\n }\n return out;\n}\n\nfunction stringToArrayHeaders(requestHeaders: string): string[] {\n const headersArray = requestHeaders.split('\\r\\n');\n const headers: string[] = [];\n for (const header of headersArray) {\n try {\n const colonIndex = header.indexOf(':');\n if (colonIndex === -1) {\n continue;\n }\n const key = header.slice(0, colonIndex).trim();\n const value = header.slice(colonIndex + 1).trim();\n if (key) {\n headers.push(key, value);\n }\n } catch {\n debug.warn(`Failed to convert string request header to array header: ${header}`);\n }\n }\n return headers;\n}\n\nfunction arrayToStringHeaders(headers: string[]): string {\n const headerPairs: string[] = [];\n\n for (let i = 0; i < headers.length; i += 2) {\n const key = headers[i];\n const value = headers[i + 1];\n if (!key || value == null) {\n // skip falsy keys but only null/undefined values\n continue;\n }\n headerPairs.push(`${key}: ${value}`);\n }\n\n if (!headerPairs.length) {\n return '';\n }\n\n return headerPairs.join('\\r\\n').concat('\\r\\n');\n}\n\n/**\n * For a given header name, if there are multiple entries in the [key, value, key, value, ...] array,\n * keep the first entry and remove the rest.\n * For baggage, values are merged to preserve all entries but to dedupe sentry- values, and always\n * keep the first occurrence of them\n */\nfunction _deduplicateArrayHeader(headers: string[], headerName: string): void {\n let firstIndex = -1;\n for (let i = 0; i < headers.length; i += 2) {\n if (headers[i] !== headerName) {\n continue;\n }\n\n if (firstIndex === -1) {\n firstIndex = i;\n continue;\n }\n\n const firstHeaderValue = headers[firstIndex + 1];\n if (headerName === SENTRY_BAGGAGE_HEADER && firstHeaderValue) {\n // mergeBaggageHeaders always takes sentry- values from the new baggage (2nd param) and merges\n // it with the existing one (1st param). Here, we want to keep the first header's existing\n // sentry- values in favor of the new ones. Hence we swap the parameters.\n const merged = mergeBaggageHeaders(headers[i + 1], firstHeaderValue);\n if (merged) {\n headers[firstIndex + 1] = merged;\n }\n }\n headers.splice(i, 2);\n i -= 2;\n }\n}\n\n/**\n * Find the index of an existing header in an array of headers.\n * Only take even indices, because headers are in format [key_0, value_0, key_1, value_1, ...]\n * otherwise we could match a header _value_ with @param name\n */\nfunction _findExistingHeaderIndex(headers: string[], name: string): number {\n return headers.findIndex((header, i) => i % 2 === 0 && header === name);\n}\n\n/** Add a breadcrumb for an outgoing fetch/undici request. */\nexport function addFetchRequestBreadcrumb(request: UndiciRequest, response: UndiciResponse): void {\n const data = getBreadcrumbData(request);\n\n const statusCode = response.statusCode;\n const level = getBreadcrumbLogLevelFromHttpStatusCode(statusCode);\n\n addBreadcrumb(\n {\n category: 'http',\n data: {\n status_code: statusCode,\n ...data,\n },\n type: 'http',\n level,\n },\n {\n event: 'response',\n request,\n response,\n },\n );\n}\n\nfunction getBreadcrumbData(request: UndiciRequest): Partial<SanitizedRequestData> {\n try {\n const url = getAbsoluteUrl(request.origin, request.path);\n const parsedUrl = parseUrl(url);\n\n return {\n url: getSanitizedUrlString(parsedUrl),\n // eslint-disable-next-line typescript/no-deprecated\n [HTTP_METHOD]: request.method || 'GET',\n [URL_QUERY]: filterCollectedUrlQuery(getUrlQuery(parsedUrl.search)),\n [URL_FRAGMENT]: getUrlFragment(parsedUrl.hash),\n };\n } catch {\n return {};\n }\n}\n\n/** Get the absolute URL from an origin and path. */\nexport function getAbsoluteUrl(origin: string, path: string = '/'): string {\n try {\n const url = new URL(path, origin);\n return url.toString();\n } catch {\n // fallback: Construct it on our own\n const url = `${origin}`;\n\n if (url.endsWith('/') && path.startsWith('/')) {\n return `${url}${path.slice(1)}`;\n }\n\n if (!url.endsWith('/') && !path.startsWith('/')) {\n return `${url}/${path}`;\n }\n\n return `${url}${path}`;\n }\n}\n"],"names":["getClient","shouldPropagateTraceForUrl","spanIsIgnored","getActiveSpan","withActiveSpan","getTraceData","mergeBaggageHeaders","debug","getBreadcrumbLogLevelFromHttpStatusCode","addBreadcrumb","parseUrl","getSanitizedUrlString","HTTP_METHOD","URL_QUERY","filterCollectedUrlQuery","getUrlQuery","URL_FRAGMENT","getUrlFragment"],"mappings":";;;;;AAoBA,MAAM,mBAAA,GAAsB,cAAA;AAC5B,MAAM,qBAAA,GAAwB,SAAA;AAC9B,MAAM,sBAAA,GAAyB,aAAA;AAcxB,SAAS,wCAAA,CACd,OAAA,EACA,sBAAA,EACA,IAAA,EACM;AACN,EAAA,MAAM,GAAA,GAAM,cAAA,CAAe,OAAA,CAAQ,MAAA,EAAQ,QAAQ,IAAI,CAAA;AAMvD,EAAA,MAAM,EAAE,yBAAyB,oBAAA,EAAqB,GAAIA,gBAAU,EAAG,UAAA,MAAgB,EAAC;AAExF,EAAA,IAAI,CAACC,+BAAA,CAA2B,GAAA,EAAK,uBAAA,EAAyB,sBAAsB,CAAA,EAAG;AACrF,IAAA;AAAA,EACF;AAIA,EAAA,MAAM,sBAAsB,IAAA,IAAQC,kBAAA,CAAc,IAAI,CAAA,IAAKC,kBAAA,KAAkB,MAAA,GAAY,IAAA;AACzF,EAAA,MAAM,YAAA,GAAe,mBAAA,GACjBC,mBAAA,CAAe,mBAAA,EAAqB,MAAMC,iBAAA,CAAa,EAAE,oBAAA,EAAsB,CAAC,CAAA,GAChFA,iBAAA,CAAa,EAAE,sBAAsB,CAAA;AAEzC,EAAA,IAAI,CAAC,YAAA,EAAc;AACjB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,EAAE,cAAA,EAAgB,WAAA,EAAa,OAAA,EAAS,aAAY,GAAI,YAAA;AAM9D,EAAA,MAAM,cAAA,GAA2B,KAAA,CAAM,OAAA,CAAQ,OAA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"version":3,"file":"outgoingFetchRequest.js","sources":["../../../src/utils/outgoingFetchRequest.ts"],"sourcesContent":["import { HTTP_REQUEST_METHOD, URL_FRAGMENT, URL_QUERY } from '@sentry/conventions/attributes';\nimport type { LRUMap, SanitizedRequestData, Span } from '@sentry/core';\nimport {\n filterCollectedUrlQuery,\n addBreadcrumb,\n getActiveSpan,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getSanitizedUrlString,\n getTraceData,\n getUrlFragment,\n getUrlQuery,\n parseUrl,\n shouldPropagateTraceForUrl,\n mergeBaggageHeaders,\n spanIsIgnored,\n withActiveSpan,\n} from '@sentry/core';\nimport type { UndiciRequest, UndiciResponse } from '../integrations/node-fetch/types';\nimport { debug } from '@sentry/core';\nconst SENTRY_TRACE_HEADER = 'sentry-trace';\nconst SENTRY_BAGGAGE_HEADER = 'baggage';\nconst W3C_TRACEPARENT_HEADER = 'traceparent';\n/**\n * Add trace propagation headers to an outgoing fetch/undici request.\n *\n * Checks if the request URL matches trace propagation targets,\n * then injects sentry-trace, traceparent, and baggage headers.\n *\n * When a `span` is passed (the outgoing `http.client` span), its trace data is propagated so downstream\n * services are parented to that span. Without a span, the active scope's trace data is used.\n *\n * Existing trace headers (e.g. set manually by the user via `getTraceData()`) always take precedence and\n * are de-duplicated rather than overwritten, so we never emit two `sentry-trace`/`baggage` entries.\n */\n// eslint-disable-next-line complexity\nexport function addTracePropagationHeadersToFetchRequest(\n request: UndiciRequest,\n propagationDecisionMap: LRUMap<string, boolean>,\n span?: Span,\n): void {\n const url = getAbsoluteUrl(request.origin, request.path);\n\n // Manually add the trace headers, if it applies\n // Note: We do not use `propagation.inject()` here, because our propagator relies on an active span\n // Which we do not have in this case\n // The propagator _may_ overwrite this, but this should be fine as it is the same data\n const { tracePropagationTargets, propagateTraceparent } = getClient()?.getOptions() || {};\n\n if (!shouldPropagateTraceForUrl(url, tracePropagationTargets, propagationDecisionMap)) {\n return;\n }\n\n // An ignored child must not become the propagation parent because no span will be emitted for it.\n // Otherwise, make the span active so the propagated headers reference it instead of its parent.\n const spanForTraceHeaders = span && spanIsIgnored(span) && getActiveSpan() ? undefined : span;\n const addedHeaders = spanForTraceHeaders\n ? withActiveSpan(spanForTraceHeaders, () => getTraceData({ propagateTraceparent }))\n : getTraceData({ propagateTraceparent });\n\n if (!addedHeaders) {\n return;\n }\n\n const { 'sentry-trace': sentryTrace, baggage, traceparent } = addedHeaders;\n\n // Undici can expose headers either as a raw string (v5-style) or as a flat array of pairs (v6-style).\n // In the array form, even indices are header names and odd indices are values; in undici v6 a value\n // may be `string | string[]` when a header has multiple values. The helpers below (_deduplicateArrayHeader,\n // push, etc.) expect each value slot to be a single string, so we normalize array headers first.\n const requestHeaders: string[] = Array.isArray(request.headers)\n ? normalizeUndiciHeaderPairs(request.headers)\n : stringToArrayHeaders(request.headers);\n\n // OTel's UndiciInstrumentation calls propagation.inject() which unconditionally\n // appends headers to the request. When the user also sets headers via getTraceData(),\n // this results in duplicate sentry-trace and baggage (and optionally traceparent) entries.\n // We clean these up before applying our own logic.\n _deduplicateArrayHeader(requestHeaders, SENTRY_TRACE_HEADER);\n _deduplicateArrayHeader(requestHeaders, SENTRY_BAGGAGE_HEADER);\n if (propagateTraceparent) {\n _deduplicateArrayHeader(requestHeaders, W3C_TRACEPARENT_HEADER);\n }\n\n // We do not want to overwrite existing headers here\n // If the core UndiciInstrumentation is registered, it will already have set the headers\n // We do not want to add any then\n const hasExistingSentryTraceHeader = _findExistingHeaderIndex(requestHeaders, SENTRY_TRACE_HEADER) !== -1;\n\n // We do not want to set any headers if we already have an existing sentry-trace header.\n // sentry-trace is still the source of truth, otherwise we risk mixing up baggage and sentry-trace values.\n if (!hasExistingSentryTraceHeader) {\n if (sentryTrace) {\n requestHeaders.push(SENTRY_TRACE_HEADER, sentryTrace);\n }\n\n if (traceparent && _findExistingHeaderIndex(requestHeaders, 'traceparent') === -1) {\n requestHeaders.push('traceparent', traceparent);\n }\n\n // For baggage, we make sure to merge this into a possibly existing header\n const existingBaggageIndex = _findExistingHeaderIndex(requestHeaders, SENTRY_BAGGAGE_HEADER);\n if (baggage && existingBaggageIndex === -1) {\n requestHeaders.push(SENTRY_BAGGAGE_HEADER, baggage);\n } else if (baggage) {\n // headers in format [key_0, value_0, key_1, value_1, ...], hence the +1 here\n const existingBaggageValue = requestHeaders[existingBaggageIndex + 1];\n const merged = mergeBaggageHeaders(existingBaggageValue, baggage);\n if (merged) {\n requestHeaders[existingBaggageIndex + 1] = merged;\n }\n }\n }\n\n if (Array.isArray(request.headers)) {\n // Replace contents in place so we keep the same array reference undici/fetch still holds.\n // `requestHeaders` is already normalized (string pairs only); splice writes them back.\n request.headers.splice(0, request.headers.length, ...requestHeaders);\n } else {\n request.headers = arrayToStringHeaders(requestHeaders);\n }\n}\n\n/**\n * Convert undici’s header array into `[name, value, name, value, ...]` where every value is a string.\n *\n * Undici v6 uses this shape: `[k1, v1, k2, v2, ...]`. Types allow each `v` to be `string | string[]` when\n * that header has multiple values. Sentry’s dedupe/merge helpers expect one string per value slot, so\n * multi-value arrays are joined with `', '`. Missing value slots become `''`.\n */\nfunction normalizeUndiciHeaderPairs(headers: (string | string[])[]): string[] {\n const out: string[] = [];\n for (let i = 0; i < headers.length; i++) {\n const entry = headers[i];\n if (i % 2 === 0) {\n // Header name (should always be a string; coerce defensively).\n out.push(typeof entry === 'string' ? entry : String(entry));\n } else {\n // Header value: flatten `string[]` to a single string for downstream string-only helpers.\n out.push(Array.isArray(entry) ? entry.join(', ') : (entry ?? ''));\n }\n }\n return out;\n}\n\nfunction stringToArrayHeaders(requestHeaders: string): string[] {\n const headersArray = requestHeaders.split('\\r\\n');\n const headers: string[] = [];\n for (const header of headersArray) {\n try {\n const colonIndex = header.indexOf(':');\n if (colonIndex === -1) {\n continue;\n }\n const key = header.slice(0, colonIndex).trim();\n const value = header.slice(colonIndex + 1).trim();\n if (key) {\n headers.push(key, value);\n }\n } catch {\n debug.warn(`Failed to convert string request header to array header: ${header}`);\n }\n }\n return headers;\n}\n\nfunction arrayToStringHeaders(headers: string[]): string {\n const headerPairs: string[] = [];\n\n for (let i = 0; i < headers.length; i += 2) {\n const key = headers[i];\n const value = headers[i + 1];\n if (!key || value == null) {\n // skip falsy keys but only null/undefined values\n continue;\n }\n headerPairs.push(`${key}: ${value}`);\n }\n\n if (!headerPairs.length) {\n return '';\n }\n\n return headerPairs.join('\\r\\n').concat('\\r\\n');\n}\n\n/**\n * For a given header name, if there are multiple entries in the [key, value, key, value, ...] array,\n * keep the first entry and remove the rest.\n * For baggage, values are merged to preserve all entries but to dedupe sentry- values, and always\n * keep the first occurrence of them\n */\nfunction _deduplicateArrayHeader(headers: string[], headerName: string): void {\n let firstIndex = -1;\n for (let i = 0; i < headers.length; i += 2) {\n if (headers[i] !== headerName) {\n continue;\n }\n\n if (firstIndex === -1) {\n firstIndex = i;\n continue;\n }\n\n const firstHeaderValue = headers[firstIndex + 1];\n if (headerName === SENTRY_BAGGAGE_HEADER && firstHeaderValue) {\n // mergeBaggageHeaders always takes sentry- values from the new baggage (2nd param) and merges\n // it with the existing one (1st param). Here, we want to keep the first header's existing\n // sentry- values in favor of the new ones. Hence we swap the parameters.\n const merged = mergeBaggageHeaders(headers[i + 1], firstHeaderValue);\n if (merged) {\n headers[firstIndex + 1] = merged;\n }\n }\n headers.splice(i, 2);\n i -= 2;\n }\n}\n\n/**\n * Find the index of an existing header in an array of headers.\n * Only take even indices, because headers are in format [key_0, value_0, key_1, value_1, ...]\n * otherwise we could match a header _value_ with @param name\n */\nfunction _findExistingHeaderIndex(headers: string[], name: string): number {\n return headers.findIndex((header, i) => i % 2 === 0 && header === name);\n}\n\n/** Add a breadcrumb for an outgoing fetch/undici request. */\nexport function addFetchRequestBreadcrumb(request: UndiciRequest, response: UndiciResponse): void {\n const data = getBreadcrumbData(request);\n\n const statusCode = response.statusCode;\n const level = getBreadcrumbLogLevelFromHttpStatusCode(statusCode);\n\n addBreadcrumb(\n {\n category: 'http',\n data: {\n status_code: statusCode,\n ...data,\n },\n type: 'http',\n level,\n },\n {\n event: 'response',\n request,\n response,\n },\n );\n}\n\nfunction getBreadcrumbData(request: UndiciRequest): Partial<SanitizedRequestData> {\n try {\n const url = getAbsoluteUrl(request.origin, request.path);\n const parsedUrl = parseUrl(url);\n\n return {\n url: getSanitizedUrlString(parsedUrl),\n // eslint-disable-next-line typescript/no-deprecated\n [HTTP_REQUEST_METHOD]: request.method || 'GET',\n [URL_QUERY]: filterCollectedUrlQuery(getUrlQuery(parsedUrl.search)),\n [URL_FRAGMENT]: getUrlFragment(parsedUrl.hash),\n };\n } catch {\n return {};\n }\n}\n\n/** Get the absolute URL from an origin and path. */\nexport function getAbsoluteUrl(origin: string, path: string = '/'): string {\n try {\n const url = new URL(path, origin);\n return url.toString();\n } catch {\n // fallback: Construct it on our own\n const url = `${origin}`;\n\n if (url.endsWith('/') && path.startsWith('/')) {\n return `${url}${path.slice(1)}`;\n }\n\n if (!url.endsWith('/') && !path.startsWith('/')) {\n return `${url}/${path}`;\n }\n\n return `${url}${path}`;\n }\n}\n"],"names":["getClient","shouldPropagateTraceForUrl","spanIsIgnored","getActiveSpan","withActiveSpan","getTraceData","mergeBaggageHeaders","debug","getBreadcrumbLogLevelFromHttpStatusCode","addBreadcrumb","parseUrl","getSanitizedUrlString","HTTP_REQUEST_METHOD","URL_QUERY","filterCollectedUrlQuery","getUrlQuery","URL_FRAGMENT","getUrlFragment"],"mappings":";;;;;AAoBA,MAAM,mBAAA,GAAsB,cAAA;AAC5B,MAAM,qBAAA,GAAwB,SAAA;AAC9B,MAAM,sBAAA,GAAyB,aAAA;AAcxB,SAAS,wCAAA,CACd,OAAA,EACA,sBAAA,EACA,IAAA,EACM;AACN,EAAA,MAAM,GAAA,GAAM,cAAA,CAAe,OAAA,CAAQ,MAAA,EAAQ,QAAQ,IAAI,CAAA;AAMvD,EAAA,MAAM,EAAE,yBAAyB,oBAAA,EAAqB,GAAIA,gBAAU,EAAG,UAAA,MAAgB,EAAC;AAExF,EAA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AA,EACtB,CAAA,CAAA,MAAQ;AAEN,IAAA,MAAM,GAAA,GAAM,GAAG,MAAM,CAAA,CAAA;AAErB,IAAA,IAAI,IAAI,QAAA,CAAS,GAAG,KAAK,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,EAAG;AAC7C,MAAA,OAAO,GAAG,GAAG,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAAA,IAC/B;AAEA,IAAA,IAAI,CAAC,IAAI,QAAA,CAAS,GAAG,KAAK,CAAC,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,EAAG;AAC/C,MAAA,OAAO,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,IACvB;AAEA,IAAA,OAAO,CAAA,EAAG,GAAG,CAAA,EAAG,IAAI,CAAA,CAAA;AAAA,EACtB;AACF;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.js","sources":["../../../src/bundler-plugin/esbuild.ts"],"sourcesContent":["import { sentryEsbuildPlugin as sentryEsbuildBundlerPlugin } from '@sentry/bundler-plugins/esbuild';\nimport type { SentryEsbuildPluginOptions as SentryEsbuildPluginOptionsBase } from '@sentry/bundler-plugins/esbuild';\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/esbuild';\n\nexport type SentryEsbuildPluginOptions = SentryEsbuildPluginOptionsBase & {\n /**\n * @ignore This is for internal use only when this plugin is consumed by a framework SDK\n */\n instrumentations?:
|
|
1
|
+
{"version":3,"file":"esbuild.js","sources":["../../../src/bundler-plugin/esbuild.ts"],"sourcesContent":["import { sentryEsbuildPlugin as sentryEsbuildBundlerPlugin } from '@sentry/bundler-plugins/esbuild';\nimport type { SentryEsbuildPluginOptions as SentryEsbuildPluginOptionsBase } from '@sentry/bundler-plugins/esbuild';\nimport type { InstrumentationConfig } from '@sentry/server-utils';\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/esbuild';\nimport type { EsbuildPlugin } from '@sentry/server-utils/orchestrion/esbuild';\n\nexport type SentryEsbuildPluginOptions = SentryEsbuildPluginOptionsBase & {\n /**\n * @ignore This is for internal use only when this plugin is consumed by a framework SDK\n */\n instrumentations?: InstrumentationConfig[];\n\n /**\n * Automatic instrumentation of server-side dependencies at build time.\n *\n * Set to `false` to turn it off.\n *\n * @default true\n */\n buildTimeInstrumentation?: boolean;\n};\n\n/**\n * esbuild plugin that bundles the Sentry esbuild bundler plugin (source maps,\n * release injection, …) together with the code transformer\n * (build-time `diagnostics_channel` instrumentation for Node libraries).\n *\n * It is a drop-in replacement for `@sentry/bundler-plugins/esbuild` and accepts\n * the same options.\n * @example\n * ```ts\n * // build.mjs\n * import { sentryEsbuildPlugin } from '@sentry/node/esbuild';\n * await esbuild.build({ plugins: [sentryEsbuildPlugin({ org: '…', project: '…' })] });\n * ```\n */\nexport function sentryEsbuildPlugin(options?: SentryEsbuildPluginOptions): EsbuildPlugin {\n const bundlerPlugin = sentryEsbuildBundlerPlugin(options) as EsbuildPlugin;\n const orchestrionPlugin = sentryOrchestrionPlugin(options);\n\n return {\n name: 'sentry-node-esbuild',\n async setup(build): Promise<void> {\n await bundlerPlugin.setup(build);\n await orchestrionPlugin.setup(build);\n },\n };\n}\n"],"names":["sentryEsbuildBundlerPlugin"],"mappings":";;;AAoCO,SAAS,oBAAoB,OAAA,EAAqD;AACvF,EAAA,MAAM,aAAA,GAAgBA,sBAA2B,OAAO,CAAA;AACxD,EAAA,MAAM,iBAAA,GAAoB,wBAAwB,OAAO,CAAA;AAEzD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,qBAAA;AAAA,IACN,MAAM,MAAM,KAAA,EAAsB;AAChC,MAAA,MAAM,aAAA,CAAc,MAAM,KAAK,CAAA;AAC/B,MAAA,MAAM,iBAAA,CAAkB,MAAM,KAAK,CAAA;AAAA,IACrC;AAAA,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sources":["../../../src/bundler-plugin/rollup.ts"],"sourcesContent":["import { sentryRollupPlugin as sentryRollupBundlerPlugin } from '@sentry/bundler-plugins/rollup';\nimport type { SentryRollupPluginOptions as SentryRollupPluginOptionsBase } from '@sentry/bundler-plugins/rollup';\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/rollup';\n\nexport type SentryRollupPluginOptions = SentryRollupPluginOptionsBase & {\n /**\n * @ignore This is for internal use only when this plugin is consumed by a framework SDK\n */\n instrumentations?:
|
|
1
|
+
{"version":3,"file":"rollup.js","sources":["../../../src/bundler-plugin/rollup.ts"],"sourcesContent":["import { sentryRollupPlugin as sentryRollupBundlerPlugin } from '@sentry/bundler-plugins/rollup';\nimport type { SentryRollupPluginOptions as SentryRollupPluginOptionsBase } from '@sentry/bundler-plugins/rollup';\nimport type { InstrumentationConfig } from '@sentry/server-utils';\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/rollup';\nimport type { RollupPlugin } from '@sentry/server-utils/orchestrion/rollup';\n\nexport type SentryRollupPluginOptions = SentryRollupPluginOptionsBase & {\n /**\n * @ignore This is for internal use only when this plugin is consumed by a framework SDK\n */\n instrumentations?: InstrumentationConfig[];\n\n /**\n * Automatic instrumentation of server-side dependencies at build time.\n *\n * Set to `false` to turn it off.\n *\n * @default true\n */\n buildTimeInstrumentation?: boolean;\n};\n\n/**\n * Rollup plugin that bundles the Sentry Rollup bundler plugin (source maps,\n * release injection, bundle size optimizations, …) together with the\n * code transformer (build-time `diagnostics_channel` instrumentation\n * for Node libraries).\n *\n * It is a drop-in replacement for `@sentry/bundler-plugins/rollup` and accepts\n * the same options.\n * @example\n * ```ts\n * // rollup.config.js\n * import { sentryRollupPlugin } from '@sentry/node/rollup';\n * export default { plugins: [sentryRollupPlugin({ org: '…', project: '…' })] };\n * ```\n */\nexport function sentryRollupPlugin(options?: SentryRollupPluginOptions): RollupPlugin[] {\n const bundlerPlugins = sentryRollupBundlerPlugin(options);\n return [...bundlerPlugins, sentryOrchestrionPlugin(options)];\n}\n"],"names":["sentryRollupBundlerPlugin"],"mappings":";;;AAqCO,SAAS,mBAAmB,OAAA,EAAqD;AACtF,EAAA,MAAM,cAAA,GAAiBA,qBAA0B,OAAO,CAAA;AACxD,EAAA,OAAO,CAAC,GAAG,cAAA,EAAgB,uBAAA,CAAwB,OAAO,CAAC,CAAA;AAC7D;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","sources":["../../../src/bundler-plugin/vite.ts"],"sourcesContent":["import { sentryVitePlugin as sentryViteBundlerPlugin } from '@sentry/bundler-plugins/vite';\nimport type { SentryVitePluginOptions as SentryVitePluginOptionsBase } from '@sentry/bundler-plugins/vite';\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite';\n\nexport type SentryVitePluginOptions = SentryVitePluginOptionsBase & {\n /**\n * @ignore This is for internal use only when this plugin is consumed by a framework SDK\n */\n instrumentations?:
|
|
1
|
+
{"version":3,"file":"vite.js","sources":["../../../src/bundler-plugin/vite.ts"],"sourcesContent":["import { sentryVitePlugin as sentryViteBundlerPlugin } from '@sentry/bundler-plugins/vite';\nimport type { SentryVitePluginOptions as SentryVitePluginOptionsBase } from '@sentry/bundler-plugins/vite';\nimport type { InstrumentationConfig } from '@sentry/server-utils';\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite';\nimport type { VitePlugin } from '@sentry/server-utils/orchestrion/vite';\n\nexport type SentryVitePluginOptions = SentryVitePluginOptionsBase & {\n /**\n * @ignore This is for internal use only when this plugin is consumed by a framework SDK\n */\n instrumentations?: InstrumentationConfig[];\n\n /**\n * Automatic instrumentation of server-side dependencies at build time.\n *\n * Set to `false` to turn it off.\n *\n * @default true\n */\n buildTimeInstrumentation?: boolean;\n};\n\n/**\n * Vite plugin that bundles the Sentry Vite bundler plugin (source maps, release\n * injection, bundle size optimizations, …) together with the code\n * transformer (build-time `diagnostics_channel` instrumentation for Node\n * libraries).\n *\n * It is a drop-in replacement for `@sentry/bundler-plugins/vite` and accepts the\n * same options.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { sentryVitePlugin } from '@sentry/node/vite';\n * export default { plugins: [sentryVitePlugin({ org: '…', project: '…' })] };\n * ```\n */\nexport function sentryVitePlugin(options?: SentryVitePluginOptions): VitePlugin[] {\n const bundlerPlugins = sentryViteBundlerPlugin(options);\n return [...bundlerPlugins, sentryOrchestrionPlugin(options)];\n}\n"],"names":["sentryViteBundlerPlugin"],"mappings":";;;AAsCO,SAAS,iBAAiB,OAAA,EAAiD;AAChF,EAAA,MAAM,cAAA,GAAiBA,mBAAwB,OAAO,CAAA;AACtD,EAAA,OAAO,CAAC,GAAG,cAAA,EAAgB,uBAAA,CAAwB,OAAO,CAAC,CAAA;AAC7D;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","sources":["../../../src/bundler-plugin/webpack.ts"],"sourcesContent":["import { sentryWebpackPlugin as sentryWebpackBundlerPlugin } from '@sentry/bundler-plugins/webpack';\nimport type { SentryWebpackPluginOptions as SentryWebpackPluginOptionsBase } from '@sentry/bundler-plugins/webpack';\nimport { sentryOrchestrionWebpackPlugin } from '@sentry/server-utils/orchestrion/webpack';\n\nexport type SentryWebpackPluginOptions = SentryWebpackPluginOptionsBase & {\n /**\n * @ignore This is for internal use only when this plugin is consumed by a framework SDK\n */\n instrumentations?:
|
|
1
|
+
{"version":3,"file":"webpack.js","sources":["../../../src/bundler-plugin/webpack.ts"],"sourcesContent":["import { sentryWebpackPlugin as sentryWebpackBundlerPlugin } from '@sentry/bundler-plugins/webpack';\nimport type { SentryWebpackPluginOptions as SentryWebpackPluginOptionsBase } from '@sentry/bundler-plugins/webpack';\nimport type { InstrumentationConfig } from '@sentry/server-utils';\nimport { sentryOrchestrionWebpackPlugin } from '@sentry/server-utils/orchestrion/webpack';\n\nexport type SentryWebpackPluginOptions = SentryWebpackPluginOptionsBase & {\n /**\n * @ignore This is for internal use only when this plugin is consumed by a framework SDK\n */\n instrumentations?: InstrumentationConfig[];\n\n /**\n * Automatic instrumentation of server-side dependencies at build time.\n *\n * Set to `false` to turn it off.\n *\n * @default true\n */\n buildTimeInstrumentation?: boolean;\n};\n\ntype WebpackCompiler = Parameters<ReturnType<typeof sentryWebpackBundlerPlugin>['apply']>[0];\n\n/**\n * webpack plugin that bundles the Sentry webpack bundler plugin (source maps,\n * release injection, …) together with the code transformer\n * (build-time `diagnostics_channel` instrumentation for Node libraries).\n *\n * It is a drop-in replacement for `@sentry/bundler-plugins/webpack` and accepts\n * the same options.\n * @example\n * ```ts\n * // webpack.config.mjs\n * import { sentryWebpackPlugin } from '@sentry/node/webpack';\n * export default { plugins: [sentryWebpackPlugin({ org: '…', project: '…' })] };\n * ```\n */\nexport function sentryWebpackPlugin(options?: SentryWebpackPluginOptions): {\n apply: (compiler: WebpackCompiler) => void;\n} {\n const bundlerPlugin = sentryWebpackBundlerPlugin(options) as { apply: (compiler: WebpackCompiler) => void };\n const orchestrionPlugin = sentryOrchestrionWebpackPlugin(options) as { apply: (compiler: WebpackCompiler) => void };\n\n return {\n apply(compiler: WebpackCompiler): void {\n bundlerPlugin.apply(compiler);\n orchestrionPlugin.apply(compiler);\n },\n };\n}\n"],"names":["sentryWebpackBundlerPlugin"],"mappings":";;;AAqCO,SAAS,oBAAoB,OAAA,EAElC;AACA,EAAA,MAAM,aAAA,GAAgBA,sBAA2B,OAAO,CAAA;AACxD,EAAA,MAAM,iBAAA,GAAoB,+BAA+B,OAAO,CAAA;AAEhE,EAAA,OAAO;AAAA,IACL,MAAM,QAAA,EAAiC;AACrC,MAAA,aAAA,CAAc,MAAM,QAAQ,CAAA;AAC5B,MAAA,iBAAA,CAAkB,MAAM,QAAQ,CAAA;AAAA,IAClC;AAAA,GACF;AACF;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
export { httpIntegration } from './integrations/http/index.js';
|
|
2
2
|
export { nativeNodeFetchIntegration } from './integrations/node-fetch/index.js';
|
|
3
3
|
export { fsIntegration } from './integrations/fs/index.js';
|
|
4
|
-
export { setupExpressErrorHandler } from '
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export { redisIntegration } from './integrations/tracing/redis/index.js';
|
|
8
|
-
export { createLangChainCallbackHandler, getOtlpTracesEndpoint, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentOpenAiClient, instrumentStateGraph, instrumentStateGraphCompile, otlpIntegration, prismaIntegration } from '@sentry/server-utils';
|
|
9
|
-
export { setupHapiErrorHandler } from './integrations/tracing/hapi/index.js';
|
|
10
|
-
export { setupKoaErrorHandler } from './integrations/tracing/koa/index.js';
|
|
4
|
+
export { amqplibIntegration, anthropicAIIntegration, createLangChainCallbackHandler, dataloaderIntegration, expressErrorHandler, expressIntegration, fastifyIntegration, firebaseIntegration, genericPoolIntegration, getOtlpTracesEndpoint, googleGenAIIntegration, graphqlIntegration, hapiIntegration, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentOpenAiClient, instrumentStateGraph, instrumentStateGraphCompile, kafkaIntegration, knexIntegration, koaIntegration, langChainIntegration, langGraphIntegration, lruMemoizerIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, openAIIntegration, otlpIntegration, postgresIntegration, postgresJsIntegration, prismaIntegration, redisIntegration, setupExpressErrorHandler, setupFastifyErrorHandler, tediousIntegration, vercelAIIntegration } from '@sentry/server-utils';
|
|
5
|
+
export { setupHapiErrorHandler } from './integrations/tracing/hapi.js';
|
|
6
|
+
export { setupKoaErrorHandler } from './integrations/tracing/koa.js';
|
|
11
7
|
export { buildLaunchDarklyFlagUsedHandlerShim as buildLaunchDarklyFlagUsedHandler, launchDarklyIntegrationShim as launchDarklyIntegration } from './integrations/featureFlagShims/launchDarkly.js';
|
|
12
8
|
export { OpenFeatureIntegrationHookShim as OpenFeatureIntegrationHook, openFeatureIntegrationShim as openFeatureIntegration } from './integrations/featureFlagShims/openFeature.js';
|
|
13
9
|
export { statsigIntegrationShim as statsigIntegration } from './integrations/featureFlagShims/statsig.js';
|
|
@@ -17,7 +13,7 @@ export { getDefaultIntegrations, getDefaultIntegrationsWithoutPerformance, init,
|
|
|
17
13
|
export { initOpenTelemetry } from './sdk/initOtel.js';
|
|
18
14
|
export { getAutoPerformanceIntegrations } from './integrations/tracing/index.js';
|
|
19
15
|
export { setOpenTelemetryContextAsyncContextStrategy } from '@sentry/opentelemetry';
|
|
20
|
-
export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
|
|
16
|
+
export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, Scope, addBreadcrumb, addEventProcessor, addIntegration, bindScopeToEmitter, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleLoggingIntegration, continueTrace, createConsolaReporter, createTransport, dedupeIntegration, endSession, eventFiltersIntegration, extraErrorDataIntegration, featureFlagsIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, httpHeadersToSpanAttributes, instrumentSupabaseClient, isEnabled, isInitialized, lastEventId, linkedErrorsIntegration, metrics, parameterize, profiler, requestDataIntegration, rewriteFramesIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, supabaseIntegration, suppressTracing, trpcMiddleware, updateSpanName, winterCGHeadersToDict, withActiveSpan, withIsolationScope, withMonitor, withScope, withStaticSpan, withStreamedSpan, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/core';
|
|
21
17
|
import * as exports$1 from './logs/exports.js';
|
|
22
18
|
export { exports$1 as logger };
|
|
23
19
|
export { childProcessIntegration } from './integrations/childProcess.js';
|
|
@@ -33,11 +29,13 @@ export { pinoIntegration } from './integrations/pino.js';
|
|
|
33
29
|
export { spotlightIntegration } from './integrations/spotlight.js';
|
|
34
30
|
export { systemErrorIntegration } from './integrations/systemError.js';
|
|
35
31
|
export { createSentryWinstonTransport } from './integrations/winston.js';
|
|
32
|
+
export { workerThreadsIntegration } from './integrations/workerThreads.js';
|
|
36
33
|
export { cron } from './cron/index.js';
|
|
37
34
|
export { NODE_VERSION } from './nodeVersion.js';
|
|
38
35
|
export { defaultStackParser, getSentryRelease } from './sdk/api.js';
|
|
39
36
|
export { makeNodeTransport } from './transports/http.js';
|
|
40
37
|
export { createGetModuleFromFilename } from './utils/module.js';
|
|
38
|
+
export { SENTRY_SEGMENT_NAME_SOURCE } from '@sentry/conventions/attributes';
|
|
41
39
|
export { httpServerIntegration } from './integrations/http/httpServerIntegration.js';
|
|
42
40
|
export { httpServerSpansIntegration } from './integrations/http/httpServerSpansIntegration.js';
|
|
43
41
|
export { processSessionIntegration } from './integrations/processSession.js';
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|