@sentry/core 10.49.0 → 10.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/fetch.js +5 -2
- package/build/cjs/fetch.js.map +1 -1
- package/build/cjs/instrument/console.js +1 -2
- package/build/cjs/instrument/console.js.map +1 -1
- package/build/cjs/integration.js +9 -0
- package/build/cjs/integration.js.map +1 -1
- package/build/cjs/integrations/mcp-server/transport.js +9 -9
- package/build/cjs/integrations/mcp-server/transport.js.map +1 -1
- package/build/cjs/integrations/requestdata.js.map +1 -1
- package/build/cjs/tracing/spans/captureSpan.js +3 -1
- package/build/cjs/tracing/spans/captureSpan.js.map +1 -1
- package/build/cjs/tracing/trace.js +17 -6
- package/build/cjs/tracing/trace.js.map +1 -1
- package/build/cjs/utils/version.js +1 -1
- package/build/esm/client.js.map +1 -1
- package/build/esm/fetch.js +5 -2
- package/build/esm/fetch.js.map +1 -1
- package/build/esm/instrument/console.js +1 -2
- package/build/esm/instrument/console.js.map +1 -1
- package/build/esm/integration.js +9 -0
- package/build/esm/integration.js.map +1 -1
- package/build/esm/integrations/mcp-server/transport.js +9 -9
- package/build/esm/integrations/mcp-server/transport.js.map +1 -1
- package/build/esm/integrations/requestdata.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/tracing/spans/captureSpan.js +3 -1
- package/build/esm/tracing/spans/captureSpan.js.map +1 -1
- package/build/esm/tracing/trace.js +17 -6
- package/build/esm/tracing/trace.js.map +1 -1
- package/build/esm/utils/version.js +1 -1
- package/build/types/client.d.ts +20 -0
- package/build/types/client.d.ts.map +1 -1
- package/build/types/fetch.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integration.d.ts.map +1 -1
- package/build/types/integrations/requestdata.d.ts.map +1 -1
- package/build/types/tracing/google-genai/types.d.ts +5 -2
- package/build/types/tracing/google-genai/types.d.ts.map +1 -1
- package/build/types/tracing/spans/captureSpan.d.ts.map +1 -1
- package/build/types/tracing/trace.d.ts.map +1 -1
- package/build/types/types-hoist/clientreport.d.ts +1 -1
- package/build/types/types-hoist/clientreport.d.ts.map +1 -1
- package/build/types/types-hoist/integration.d.ts +13 -0
- package/build/types/types-hoist/integration.d.ts.map +1 -1
- package/build/types/types-hoist/replay.d.ts +25 -0
- package/build/types/types-hoist/replay.d.ts.map +1 -1
- package/build/types-ts3.8/client.d.ts +20 -0
- package/build/types-ts3.8/index.d.ts +3 -2
- package/build/types-ts3.8/tracing/google-genai/types.d.ts +5 -2
- package/build/types-ts3.8/types-hoist/clientreport.d.ts +1 -1
- package/build/types-ts3.8/types-hoist/integration.d.ts +13 -0
- package/build/types-ts3.8/types-hoist/replay.d.ts +25 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sources":["../../../src/instrument/console.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { ConsoleLevel, HandlerDataConsole } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger';\nimport { fill } from '../utils/object';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers';\n\n/**\n * Add an instrumentation handler for when a console.xxx method is called.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): void {\n const type = 'console';\n addHandler(type, handler);\n maybeInstrument(type, instrumentConsole);\n}\n\nfunction instrumentConsole(): void {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n CONSOLE_LEVELS.forEach(function (level: ConsoleLevel): void {\n if (!(level in GLOBAL_OBJ.console)) {\n return;\n }\n\n fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod: () => any): Function {\n originalConsoleMethods[level] = originalConsoleMethod;\n\n return function (...args: any[]): void {\n
|
|
1
|
+
{"version":3,"file":"console.js","sources":["../../../src/instrument/console.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { ConsoleLevel, HandlerDataConsole } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger';\nimport { fill } from '../utils/object';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers';\n\n/**\n * Add an instrumentation handler for when a console.xxx method is called.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): void {\n const type = 'console';\n addHandler(type, handler);\n maybeInstrument(type, instrumentConsole);\n}\n\nfunction instrumentConsole(): void {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n CONSOLE_LEVELS.forEach(function (level: ConsoleLevel): void {\n if (!(level in GLOBAL_OBJ.console)) {\n return;\n }\n\n fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod: () => any): Function {\n originalConsoleMethods[level] = originalConsoleMethod;\n\n return function (...args: any[]): void {\n triggerHandlers('console', { args, level } as HandlerDataConsole);\n\n const log = originalConsoleMethods[level];\n log?.apply(GLOBAL_OBJ.console, args);\n };\n });\n });\n}\n"],"names":["addHandler","maybeInstrument","GLOBAL_OBJ","CONSOLE_LEVELS","fill","originalConsoleMethods","triggerHandlers"],"mappings":";;;;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,OAAO,EAA4C;AACpG,EAAE,MAAM,IAAA,GAAO,SAAS;AACxB,EAAEA,mBAAU,CAAC,IAAI,EAAE,OAAO,CAAC;AAC3B,EAAEC,wBAAe,CAAC,IAAI,EAAE,iBAAiB,CAAC;AAC1C;;AAEA,SAAS,iBAAiB,GAAS;AACnC,EAAE,IAAI,EAAE,aAAaC,oBAAU,CAAC,EAAE;AAClC,IAAI;AACJ,EAAE;;AAEF,EAAEC,0BAAc,CAAC,OAAO,CAAC,UAAU,KAAK,EAAsB;AAC9D,IAAI,IAAI,EAAE,KAAA,IAASD,oBAAU,CAAC,OAAO,CAAC,EAAE;AACxC,MAAM;AACN,IAAI;;AAEJ,IAAIE,WAAI,CAACF,oBAAU,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,qBAAqB,EAAuB;AAC1F,MAAMG,kCAAsB,CAAC,KAAK,CAAA,GAAI,qBAAqB;;AAE3D,MAAM,OAAO,UAAU,GAAG,IAAI,EAAe;AAC7C,QAAQC,wBAAe,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,KAAA,EAAM,EAAwB;;AAEzE,QAAQ,MAAM,GAAA,GAAMD,kCAAsB,CAAC,KAAK,CAAC;AACjD,QAAQ,GAAG,EAAE,KAAK,CAACH,oBAAU,CAAC,OAAO,EAAE,IAAI,CAAC;AAC5C,MAAM,CAAC;AACP,IAAI,CAAC,CAAC;AACN,EAAE,CAAC,CAAC;AACJ;;;;"}
|
package/build/cjs/integration.js
CHANGED
|
@@ -131,6 +131,15 @@ function setupIntegration(client, integration, integrationIndex) {
|
|
|
131
131
|
client.addEventProcessor(processor);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
(['processSpan', 'processSegmentSpan'] ).forEach(hook => {
|
|
135
|
+
const callback = integration[hook];
|
|
136
|
+
if (typeof callback === 'function') {
|
|
137
|
+
// The cast is needed because TS can't resolve overloads when the discriminant is a union type.
|
|
138
|
+
// Both overloads have the same callback signature so this is safe.
|
|
139
|
+
client.on(hook , (span) => callback.call(integration, span, client));
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
134
143
|
debugBuild.DEBUG_BUILD && debugLogger.debug.log(`Integration installed: ${integration.name}`);
|
|
135
144
|
}
|
|
136
145
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sources":["../../src/integration.ts"],"sourcesContent":["import type { Client } from './client';\nimport { getClient } from './currentScopes';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { Event, EventHint } from './types-hoist/event';\nimport type { Integration, IntegrationFn } from './types-hoist/integration';\nimport type { CoreOptions } from './types-hoist/options';\nimport { debug } from './utils/debug-logger';\n\nexport const installedIntegrations: string[] = [];\n\n/** Map of integrations assigned to a client */\nexport type IntegrationIndex = {\n [key: string]: Integration;\n};\n\ntype IntegrationWithDefaultInstance = Integration & { isDefaultInstance?: true };\n\n/**\n * Remove duplicates from the given array, preferring the last instance of any duplicate. Not guaranteed to\n * preserve the order of integrations in the array.\n *\n * @private\n */\nfunction filterDuplicates(integrations: Integration[]): Integration[] {\n const integrationsByName: { [key: string]: Integration } = {};\n\n integrations.forEach((currentInstance: IntegrationWithDefaultInstance) => {\n const { name } = currentInstance;\n\n const existingInstance: IntegrationWithDefaultInstance | undefined = integrationsByName[name];\n\n // We want integrations later in the array to overwrite earlier ones of the same type, except that we never want a\n // default instance to overwrite an existing user instance\n if (existingInstance && !existingInstance.isDefaultInstance && currentInstance.isDefaultInstance) {\n return;\n }\n\n integrationsByName[name] = currentInstance;\n });\n\n return Object.values(integrationsByName);\n}\n\n/** Gets integrations to install */\nexport function getIntegrationsToSetup(\n options: Pick<CoreOptions, 'defaultIntegrations' | 'integrations'>,\n): Integration[] {\n const defaultIntegrations = options.defaultIntegrations || [];\n const userIntegrations = options.integrations;\n\n // We flag default instances, so that later we can tell them apart from any user-created instances of the same class\n defaultIntegrations.forEach((integration: IntegrationWithDefaultInstance) => {\n integration.isDefaultInstance = true;\n });\n\n let integrations: Integration[];\n\n if (Array.isArray(userIntegrations)) {\n integrations = [...defaultIntegrations, ...userIntegrations];\n } else if (typeof userIntegrations === 'function') {\n const resolvedUserIntegrations = userIntegrations(defaultIntegrations);\n integrations = Array.isArray(resolvedUserIntegrations) ? resolvedUserIntegrations : [resolvedUserIntegrations];\n } else {\n integrations = defaultIntegrations;\n }\n\n return filterDuplicates(integrations);\n}\n\n/**\n * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default\n * integrations are added unless they were already provided before.\n * @param integrations array of integration instances\n * @param withDefault should enable default integrations\n */\nexport function setupIntegrations(client: Client, integrations: Integration[]): IntegrationIndex {\n const integrationIndex: IntegrationIndex = {};\n\n integrations.forEach((integration: Integration | undefined) => {\n if (integration?.beforeSetup) {\n integration.beforeSetup(client);\n }\n });\n\n integrations.forEach((integration: Integration | undefined) => {\n // guard against empty provided integrations\n if (integration) {\n setupIntegration(client, integration, integrationIndex);\n }\n });\n\n return integrationIndex;\n}\n\n/**\n * Execute the `afterAllSetup` hooks of the given integrations.\n */\nexport function afterSetupIntegrations(client: Client, integrations: Integration[]): void {\n for (const integration of integrations) {\n // guard against empty provided integrations\n if (integration?.afterAllSetup) {\n integration.afterAllSetup(client);\n }\n }\n}\n\n/** Setup a single integration. */\nexport function setupIntegration(client: Client, integration: Integration, integrationIndex: IntegrationIndex): void {\n if (integrationIndex[integration.name]) {\n DEBUG_BUILD && debug.log(`Integration skipped because it was already installed: ${integration.name}`);\n return;\n }\n integrationIndex[integration.name] = integration;\n\n // `setupOnce` is only called the first time\n if (!installedIntegrations.includes(integration.name) && typeof integration.setupOnce === 'function') {\n integration.setupOnce();\n installedIntegrations.push(integration.name);\n }\n\n // `setup` is run for each client\n if (integration.setup && typeof integration.setup === 'function') {\n integration.setup(client);\n }\n\n if (typeof integration.preprocessEvent === 'function') {\n const callback = integration.preprocessEvent.bind(integration) as typeof integration.preprocessEvent;\n client.on('preprocessEvent', (event, hint) => callback(event, hint, client));\n }\n\n if (typeof integration.processEvent === 'function') {\n const callback = integration.processEvent.bind(integration) as typeof integration.processEvent;\n\n const processor = Object.assign((event: Event, hint: EventHint) => callback(event, hint, client), {\n id: integration.name,\n });\n\n client.addEventProcessor(processor);\n }\n\n DEBUG_BUILD && debug.log(`Integration installed: ${integration.name}`);\n}\n\n/** Add an integration to the current scope's client. */\nexport function addIntegration(integration: Integration): void {\n const client = getClient();\n\n if (!client) {\n DEBUG_BUILD && debug.warn(`Cannot add integration \"${integration.name}\" because no SDK Client is available.`);\n return;\n }\n\n client.addIntegration(integration);\n}\n\n/**\n * Define an integration function that can be used to create an integration instance.\n * Note that this by design hides the implementation details of the integration, as they are considered internal.\n */\nexport function defineIntegration<Fn extends IntegrationFn>(fn: Fn): (...args: Parameters<Fn>) => Integration {\n return fn;\n}\n"],"names":["DEBUG_BUILD","debug","getClient"],"mappings":";;;;;;AAQO,MAAM,qBAAqB,GAAa;;AAE/C;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,gBAAgB,CAAC,YAAY,EAAgC;AACtE,EAAE,MAAM,kBAAkB,GAAmC,EAAE;;AAE/D,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,eAAe,KAAqC;AAC5E,IAAI,MAAM,EAAE,IAAA,EAAK,GAAI,eAAe;;AAEpC,IAAI,MAAM,gBAAgB,GAA+C,kBAAkB,CAAC,IAAI,CAAC;;AAEjG;AACA;AACA,IAAI,IAAI,gBAAA,IAAoB,CAAC,gBAAgB,CAAC,iBAAA,IAAqB,eAAe,CAAC,iBAAiB,EAAE;AACtG,MAAM;AACN,IAAI;;AAEJ,IAAI,kBAAkB,CAAC,IAAI,CAAA,GAAI,eAAe;AAC9C,EAAE,CAAC,CAAC;;AAEJ,EAAE,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC;AAC1C;;AAEA;AACO,SAAS,sBAAsB;AACtC,EAAE,OAAO;AACT,EAAiB;AACjB,EAAE,MAAM,sBAAsB,OAAO,CAAC,mBAAA,IAAuB,EAAE;AAC/D,EAAE,MAAM,gBAAA,GAAmB,OAAO,CAAC,YAAY;;AAE/C;AACA,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,WAAW,KAAqC;AAC/E,IAAI,WAAW,CAAC,iBAAA,GAAoB,IAAI;AACxC,EAAE,CAAC,CAAC;;AAEJ,EAAE,IAAI,YAAY;;AAElB,EAAE,I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,KAAA,EAAA,IAAA,EAAA,MAAA,CAAA,EAAA;AACA,MAAA,EAAA,EAAA,WAAA,CAAA,IAAA;AACA,KAAA,CAAA;;AAEA,IAAA,MAAA,CAAA,iBAAA,CAAA,SAAA,CAAA;AACA,EAAA;;AAEA,EAAAD,sBAAA,IAAAC,iBAAA,CAAA,GAAA,CAAA,CAAA,uBAAA,EAAA,WAAA,CAAA,IAAA,CAAA,CAAA,CAAA;AACA;;AAEA;AACA,SAAA,cAAA,CAAA,WAAA,EAAA;AACA,EAAA,MAAA,MAAA,GAAAC,uBAAA,EAAA;;AAEA,EAAA,IAAA,CAAA,MAAA,EAAA;AACA,IAAAF,sBAAA,IAAAC,iBAAA,CAAA,IAAA,CAAA,CAAA,wBAAA,EAAA,WAAA,CAAA,IAAA,CAAA,qCAAA,CAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,CAAA,cAAA,CAAA,WAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAA,iBAAA,CAAA,EAAA,EAAA;AACA,EAAA,OAAA,EAAA;AACA;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"integration.js","sources":["../../src/integration.ts"],"sourcesContent":["import type { Client } from './client';\nimport { getClient } from './currentScopes';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { Event, EventHint } from './types-hoist/event';\nimport type { Integration, IntegrationFn } from './types-hoist/integration';\nimport type { CoreOptions } from './types-hoist/options';\nimport type { StreamedSpanJSON } from './types-hoist/span';\nimport { debug } from './utils/debug-logger';\n\nexport const installedIntegrations: string[] = [];\n\n/** Map of integrations assigned to a client */\nexport type IntegrationIndex = {\n [key: string]: Integration;\n};\n\ntype IntegrationWithDefaultInstance = Integration & { isDefaultInstance?: true };\n\n/**\n * Remove duplicates from the given array, preferring the last instance of any duplicate. Not guaranteed to\n * preserve the order of integrations in the array.\n *\n * @private\n */\nfunction filterDuplicates(integrations: Integration[]): Integration[] {\n const integrationsByName: { [key: string]: Integration } = {};\n\n integrations.forEach((currentInstance: IntegrationWithDefaultInstance) => {\n const { name } = currentInstance;\n\n const existingInstance: IntegrationWithDefaultInstance | undefined = integrationsByName[name];\n\n // We want integrations later in the array to overwrite earlier ones of the same type, except that we never want a\n // default instance to overwrite an existing user instance\n if (existingInstance && !existingInstance.isDefaultInstance && currentInstance.isDefaultInstance) {\n return;\n }\n\n integrationsByName[name] = currentInstance;\n });\n\n return Object.values(integrationsByName);\n}\n\n/** Gets integrations to install */\nexport function getIntegrationsToSetup(\n options: Pick<CoreOptions, 'defaultIntegrations' | 'integrations'>,\n): Integration[] {\n const defaultIntegrations = options.defaultIntegrations || [];\n const userIntegrations = options.integrations;\n\n // We flag default instances, so that later we can tell them apart from any user-created instances of the same class\n defaultIntegrations.forEach((integration: IntegrationWithDefaultInstance) => {\n integration.isDefaultInstance = true;\n });\n\n let integrations: Integration[];\n\n if (Array.isArray(userIntegrations)) {\n integrations = [...defaultIntegrations, ...userIntegrations];\n } else if (typeof userIntegrations === 'function') {\n const resolvedUserIntegrations = userIntegrations(defaultIntegrations);\n integrations = Array.isArray(resolvedUserIntegrations) ? resolvedUserIntegrations : [resolvedUserIntegrations];\n } else {\n integrations = defaultIntegrations;\n }\n\n return filterDuplicates(integrations);\n}\n\n/**\n * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default\n * integrations are added unless they were already provided before.\n * @param integrations array of integration instances\n * @param withDefault should enable default integrations\n */\nexport function setupIntegrations(client: Client, integrations: Integration[]): IntegrationIndex {\n const integrationIndex: IntegrationIndex = {};\n\n integrations.forEach((integration: Integration | undefined) => {\n if (integration?.beforeSetup) {\n integration.beforeSetup(client);\n }\n });\n\n integrations.forEach((integration: Integration | undefined) => {\n // guard against empty provided integrations\n if (integration) {\n setupIntegration(client, integration, integrationIndex);\n }\n });\n\n return integrationIndex;\n}\n\n/**\n * Execute the `afterAllSetup` hooks of the given integrations.\n */\nexport function afterSetupIntegrations(client: Client, integrations: Integration[]): void {\n for (const integration of integrations) {\n // guard against empty provided integrations\n if (integration?.afterAllSetup) {\n integration.afterAllSetup(client);\n }\n }\n}\n\n/** Setup a single integration. */\nexport function setupIntegration(client: Client, integration: Integration, integrationIndex: IntegrationIndex): void {\n if (integrationIndex[integration.name]) {\n DEBUG_BUILD && debug.log(`Integration skipped because it was already installed: ${integration.name}`);\n return;\n }\n integrationIndex[integration.name] = integration;\n\n // `setupOnce` is only called the first time\n if (!installedIntegrations.includes(integration.name) && typeof integration.setupOnce === 'function') {\n integration.setupOnce();\n installedIntegrations.push(integration.name);\n }\n\n // `setup` is run for each client\n if (integration.setup && typeof integration.setup === 'function') {\n integration.setup(client);\n }\n\n if (typeof integration.preprocessEvent === 'function') {\n const callback = integration.preprocessEvent.bind(integration) as typeof integration.preprocessEvent;\n client.on('preprocessEvent', (event, hint) => callback(event, hint, client));\n }\n\n if (typeof integration.processEvent === 'function') {\n const callback = integration.processEvent.bind(integration) as typeof integration.processEvent;\n\n const processor = Object.assign((event: Event, hint: EventHint) => callback(event, hint, client), {\n id: integration.name,\n });\n\n client.addEventProcessor(processor);\n }\n\n (['processSpan', 'processSegmentSpan'] as const).forEach(hook => {\n const callback = integration[hook];\n if (typeof callback === 'function') {\n // The cast is needed because TS can't resolve overloads when the discriminant is a union type.\n // Both overloads have the same callback signature so this is safe.\n client.on(hook as 'processSpan', (span: StreamedSpanJSON) => callback.call(integration, span, client));\n }\n });\n\n DEBUG_BUILD && debug.log(`Integration installed: ${integration.name}`);\n}\n\n/** Add an integration to the current scope's client. */\nexport function addIntegration(integration: Integration): void {\n const client = getClient();\n\n if (!client) {\n DEBUG_BUILD && debug.warn(`Cannot add integration \"${integration.name}\" because no SDK Client is available.`);\n return;\n }\n\n client.addIntegration(integration);\n}\n\n/**\n * Define an integration function that can be used to create an integration instance.\n * Note that this by design hides the implementation details of the integration, as they are considered internal.\n */\nexport function defineIntegration<Fn extends IntegrationFn>(fn: Fn): (...args: Parameters<Fn>) => Integration {\n return fn;\n}\n"],"names":["DEBUG_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AA,CAAA,IAAA,CAAA;AACA,IAAA,IAAA,OAAA,QAAA,KAAA,UAAA,EAAA;AACA;AACA;AACA,MAAA,MAAA,CAAA,EAAA,CAAA,IAAA,GAAA,CAAA,IAAA,KAAA,QAAA,CAAA,IAAA,CAAA,WAAA,EAAA,IAAA,EAAA,MAAA,CAAA,CAAA;AACA,IAAA;AACA,EAAA,CAAA,CAAA;;AAEA,EAAAD,sBAAA,IAAAC,iBAAA,CAAA,GAAA,CAAA,CAAA,uBAAA,EAAA,WAAA,CAAA,IAAA,CAAA,CAAA,CAAA;AACA;;AAEA;AACA,SAAA,cAAA,CAAA,WAAA,EAAA;AACA,EAAA,MAAA,MAAA,GAAAC,uBAAA,EAAA;;AAEA,EAAA,IAAA,CAAA,MAAA,EAAA;AACA,IAAAF,sBAAA,IAAAC,iBAAA,CAAA,IAAA,CAAA,CAAA,wBAAA,EAAA,WAAA,CAAA,IAAA,CAAA,qCAAA,CAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,CAAA,cAAA,CAAA,WAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAA,iBAAA,CAAA,EAAA,EAAA;AACA,EAAA,OAAA,EAAA;AACA;;;;;;;;;;"}
|
|
@@ -37,7 +37,7 @@ function wrapTransportOnMessage(transport, options) {
|
|
|
37
37
|
if (isInitialize) {
|
|
38
38
|
try {
|
|
39
39
|
initSessionData = sessionExtraction.extractSessionDataFromInitializeRequest(message);
|
|
40
|
-
sessionManagement.storeSessionDataForTransport(
|
|
40
|
+
sessionManagement.storeSessionDataForTransport(transport, initSessionData);
|
|
41
41
|
} catch {
|
|
42
42
|
// noop
|
|
43
43
|
}
|
|
@@ -46,7 +46,7 @@ function wrapTransportOnMessage(transport, options) {
|
|
|
46
46
|
const isolationScope = currentScopes.getIsolationScope().clone();
|
|
47
47
|
|
|
48
48
|
return currentScopes.withIsolationScope(isolationScope, () => {
|
|
49
|
-
const spanConfig = spans.buildMcpServerSpanConfig(message,
|
|
49
|
+
const spanConfig = spans.buildMcpServerSpanConfig(message, transport, extra , options);
|
|
50
50
|
const span = trace.startInactiveSpan(spanConfig);
|
|
51
51
|
|
|
52
52
|
// For initialize requests, add client info directly to span (works even for stateless transports)
|
|
@@ -59,7 +59,7 @@ function wrapTransportOnMessage(transport, options) {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
correlation.storeSpanForRequest(
|
|
62
|
+
correlation.storeSpanForRequest(transport, message.id, span, message.method);
|
|
63
63
|
|
|
64
64
|
return trace.withActiveSpan(span, () => {
|
|
65
65
|
return (originalOnMessage ).call(this, message, extra);
|
|
@@ -68,7 +68,7 @@ function wrapTransportOnMessage(transport, options) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (validation.isJsonRpcNotification(message)) {
|
|
71
|
-
return spans.createMcpNotificationSpan(message,
|
|
71
|
+
return spans.createMcpNotificationSpan(message, transport, extra , options, () => {
|
|
72
72
|
return (originalOnMessage ).call(this, message, extra);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
@@ -93,7 +93,7 @@ function wrapTransportSend(transport, options) {
|
|
|
93
93
|
const [message] = args;
|
|
94
94
|
|
|
95
95
|
if (validation.isJsonRpcNotification(message)) {
|
|
96
|
-
return spans.createMcpOutgoingNotificationSpan(message,
|
|
96
|
+
return spans.createMcpOutgoingNotificationSpan(message, transport, options, () => {
|
|
97
97
|
return (originalSend ).call(this, ...args);
|
|
98
98
|
});
|
|
99
99
|
}
|
|
@@ -108,14 +108,14 @@ function wrapTransportSend(transport, options) {
|
|
|
108
108
|
if (message.result.protocolVersion || message.result.serverInfo) {
|
|
109
109
|
try {
|
|
110
110
|
const serverData = sessionExtraction.extractSessionDataFromInitializeResponse(message.result);
|
|
111
|
-
sessionManagement.updateSessionDataForTransport(
|
|
111
|
+
sessionManagement.updateSessionDataForTransport(transport, serverData);
|
|
112
112
|
} catch {
|
|
113
113
|
// noop
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
correlation.completeSpanWithResults(
|
|
118
|
+
correlation.completeSpanWithResults(transport, message.id, message.result, options, !!message.error);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -133,8 +133,8 @@ function wrapTransportOnClose(transport) {
|
|
|
133
133
|
if (transport.onclose) {
|
|
134
134
|
object.fill(transport, 'onclose', originalOnClose => {
|
|
135
135
|
return function ( ...args) {
|
|
136
|
-
correlation.cleanupPendingSpansForTransport(
|
|
137
|
-
sessionManagement.cleanupSessionDataForTransport(
|
|
136
|
+
correlation.cleanupPendingSpansForTransport(transport);
|
|
137
|
+
sessionManagement.cleanupSessionDataForTransport(transport);
|
|
138
138
|
return (originalOnClose ).call(this, ...args);
|
|
139
139
|
};
|
|
140
140
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sources":["../../../../src/integrations/mcp-server/transport.ts"],"sourcesContent":["/**\n * Transport layer instrumentation for MCP server\n *\n * Handles message interception and response correlation.\n * @see https://modelcontextprotocol.io/specification/2025-06-18/basic/transports\n */\n\nimport { getIsolationScope, withIsolationScope } from '../../currentScopes';\nimport { startInactiveSpan, withActiveSpan } from '../../tracing';\nimport { fill } from '../../utils/object';\nimport { MCP_PROTOCOL_VERSION_ATTRIBUTE } from './attributes';\nimport { cleanupPendingSpansForTransport, completeSpanWithResults, storeSpanForRequest } from './correlation';\nimport { captureError } from './errorCapture';\nimport {\n buildClientAttributesFromInfo,\n extractSessionDataFromInitializeRequest,\n extractSessionDataFromInitializeResponse,\n} from './sessionExtraction';\nimport {\n cleanupSessionDataForTransport,\n storeSessionDataForTransport,\n updateSessionDataForTransport,\n} from './sessionManagement';\nimport { buildMcpServerSpanConfig, createMcpNotificationSpan, createMcpOutgoingNotificationSpan } from './spans';\nimport type { ExtraHandlerData, MCPTransport, ResolvedMcpOptions, SessionData } from './types';\nimport { isJsonRpcNotification, isJsonRpcRequest, isJsonRpcResponse, isValidContentItem } from './validation';\n\n/**\n * Wraps transport.onmessage to create spans for incoming messages.\n * For \"initialize\" requests, extracts and stores client info and protocol version\n * in the session data for the transport.\n * @param transport - MCP transport instance to wrap\n * @param options - Resolved MCP options\n */\nexport function wrapTransportOnMessage(transport: MCPTransport, options: ResolvedMcpOptions): void {\n if (transport.onmessage) {\n fill(transport, 'onmessage', originalOnMessage => {\n return function (this: MCPTransport, message: unknown, extra?: unknown) {\n if (isJsonRpcRequest(message)) {\n const isInitialize = message.method === 'initialize';\n let initSessionData: SessionData | undefined;\n\n if (isInitialize) {\n try {\n initSessionData = extractSessionDataFromInitializeRequest(message);\n storeSessionDataForTransport(this, initSessionData);\n } catch {\n // noop\n }\n }\n\n const isolationScope = getIsolationScope().clone();\n\n return withIsolationScope(isolationScope, () => {\n const spanConfig = buildMcpServerSpanConfig(message, this, extra as ExtraHandlerData, options);\n const span = startInactiveSpan(spanConfig);\n\n // For initialize requests, add client info directly to span (works even for stateless transports)\n if (isInitialize && initSessionData) {\n span.setAttributes({\n ...buildClientAttributesFromInfo(initSessionData.clientInfo),\n ...(initSessionData.protocolVersion && {\n [MCP_PROTOCOL_VERSION_ATTRIBUTE]: initSessionData.protocolVersion,\n }),\n });\n }\n\n storeSpanForRequest(this, message.id, span, message.method);\n\n return withActiveSpan(span, () => {\n return (originalOnMessage as (...args: unknown[]) => unknown).call(this, message, extra);\n });\n });\n }\n\n if (isJsonRpcNotification(message)) {\n return createMcpNotificationSpan(message, this, extra as ExtraHandlerData, options, () => {\n return (originalOnMessage as (...args: unknown[]) => unknown).call(this, message, extra);\n });\n }\n\n return (originalOnMessage as (...args: unknown[]) => unknown).call(this, message, extra);\n };\n });\n }\n}\n\n/**\n * Wraps transport.send to handle outgoing messages and response correlation.\n * For \"initialize\" responses, extracts and stores protocol version and server info\n * in the session data for the transport.\n * @param transport - MCP transport instance to wrap\n * @param options - Resolved MCP options\n */\nexport function wrapTransportSend(transport: MCPTransport, options: ResolvedMcpOptions): void {\n if (transport.send) {\n fill(transport, 'send', originalSend => {\n return async function (this: MCPTransport, ...args: unknown[]) {\n const [message] = args;\n\n if (isJsonRpcNotification(message)) {\n return createMcpOutgoingNotificationSpan(message, this, options, () => {\n return (originalSend as (...args: unknown[]) => unknown).call(this, ...args);\n });\n }\n\n if (isJsonRpcResponse(message)) {\n if (message.id !== null && message.id !== undefined) {\n if (message.error) {\n captureJsonRpcErrorResponse(message.error);\n }\n\n if (isValidContentItem(message.result)) {\n if (message.result.protocolVersion || message.result.serverInfo) {\n try {\n const serverData = extractSessionDataFromInitializeResponse(message.result);\n updateSessionDataForTransport(this, serverData);\n } catch {\n // noop\n }\n }\n }\n\n completeSpanWithResults(this, message.id, message.result, options, !!message.error);\n }\n }\n\n return (originalSend as (...args: unknown[]) => unknown).call(this, ...args);\n };\n });\n }\n}\n\n/**\n * Wraps transport.onclose to clean up pending spans for this transport only\n * @param transport - MCP transport instance to wrap\n */\nexport function wrapTransportOnClose(transport: MCPTransport): void {\n if (transport.onclose) {\n fill(transport, 'onclose', originalOnClose => {\n return function (this: MCPTransport, ...args: unknown[]) {\n cleanupPendingSpansForTransport(this);\n cleanupSessionDataForTransport(this);\n return (originalOnClose as (...args: unknown[]) => unknown).call(this, ...args);\n };\n });\n }\n}\n\n/**\n * Wraps transport error handlers to capture connection errors\n * @param transport - MCP transport instance to wrap\n */\nexport function wrapTransportError(transport: MCPTransport): void {\n if (transport.onerror) {\n fill(transport, 'onerror', (originalOnError: (error: Error) => void) => {\n return function (this: MCPTransport, error: Error) {\n captureTransportError(error);\n return originalOnError.call(this, error);\n };\n });\n }\n}\n\n/**\n * Captures JSON-RPC error responses for server-side errors.\n * @see https://www.jsonrpc.org/specification#error_object\n * @internal\n * @param errorResponse - JSON-RPC error response\n */\nfunction captureJsonRpcErrorResponse(errorResponse: unknown): void {\n try {\n if (errorResponse && typeof errorResponse === 'object' && 'code' in errorResponse && 'message' in errorResponse) {\n const jsonRpcError = errorResponse as { code: number; message: string; data?: unknown };\n\n const isServerError =\n jsonRpcError.code === -32603 || (jsonRpcError.code >= -32099 && jsonRpcError.code <= -32000);\n\n if (isServerError) {\n const error = new Error(jsonRpcError.message);\n error.name = `JsonRpcError_${jsonRpcError.code}`;\n\n captureError(error, 'protocol');\n }\n }\n } catch {\n // noop\n }\n}\n\n/**\n * Captures transport connection errors\n * @internal\n * @param error - Transport error\n */\nfunction captureTransportError(error: Error): void {\n try {\n captureError(error, 'transport');\n } catch {\n // noop\n }\n}\n"],"names":["fill","isJsonRpcRequest","extractSessionDataFromInitializeRequest","storeSessionDataForTransport","getIsolationScope","withIsolationScope","buildMcpServerSpanConfig","startInactiveSpan","buildClientAttributesFromInfo","MCP_PROTOCOL_VERSION_ATTRIBUTE","storeSpanForRequest","withActiveSpan","isJsonRpcNotification","createMcpNotificationSpan","createMcpOutgoingNotificationSpan","isJsonRpcResponse","isValidContentItem","extractSessionDataFromInitializeResponse","updateSessionDataForTransport","completeSpanWithResults","cleanupPendingSpansForTransport","cleanupSessionDataForTransport","captureError"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,sBAAsB,CAAC,SAAS,EAAgB,OAAO,EAA4B;AACnG,EAAE,IAAI,SAAS,CAAC,SAAS,EAAE;AAC3B,IAAIA,WAAI,CAAC,SAAS,EAAE,WAAW,EAAE,qBAAqB;AACtD,MAAM,OAAO,WAA8B,OAAO,EAAW,KAAK,EAAY;AAC9E,QAAQ,IAAIC,2BAAgB,CAAC,OAAO,CAAC,EAAE;AACvC,UAAU,MAAM,YAAA,GAAe,OAAO,CAAC,MAAA,KAAW,YAAY;AAC9D,UAAU,IAAI,eAAe;;AAE7B,UAAU,IAAI,YAAY,EAAE;AAC5B,YAAY,IAAI;AAChB,cAAc,eAAA,GAAkBC,yDAAuC,CAAC,OAAO,CAAC;AAChF,cAAcC,8CAA4B,CAAC,IAAI,EAAE,eAAe,CAAC;AAC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iB,OAAO,kBAAkB,QAAA,IAAY,MAAA,IAAU,aAAA,IAAiB,SAAA,IAAa,aAAa,EAAE;AACrH,MAAM,MAAM,YAAA,GAAe,aAAA;;AAE3B,MAAM,MAAM,aAAA;AACZ,QAAQ,YAAY,CAAC,IAAA,KAAS,CAAC,KAAA,KAAU,YAAY,CAAC,QAAQ,CAAC,SAAS,YAAY,CAAC,IAAA,IAAQ,CAAC,KAAK,CAAC;;AAEpG,MAAM,IAAI,aAAa,EAAE;AACzB,QAAQ,MAAM,QAAQ,IAAI,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC;AACrD,QAAQ,KAAK,CAAC,IAAA,GAAO,CAAC,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,CAAA;;AAEA,QAAAsB,yBAAA,CAAA,KAAA,EAAA,UAAA,CAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA,CAAA,CAAA,MAAA;AACA;AACA,EAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAA,qBAAA,CAAA,KAAA,EAAA;AACA,EAAA,IAAA;AACA,IAAAA,yBAAA,CAAA,KAAA,EAAA,WAAA,CAAA;AACA,EAAA,CAAA,CAAA,MAAA;AACA;AACA,EAAA;AACA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"transport.js","sources":["../../../../src/integrations/mcp-server/transport.ts"],"sourcesContent":["/**\n * Transport layer instrumentation for MCP server\n *\n * Handles message interception and response correlation.\n * @see https://modelcontextprotocol.io/specification/2025-06-18/basic/transports\n */\n\nimport { getIsolationScope, withIsolationScope } from '../../currentScopes';\nimport { startInactiveSpan, withActiveSpan } from '../../tracing';\nimport { fill } from '../../utils/object';\nimport { MCP_PROTOCOL_VERSION_ATTRIBUTE } from './attributes';\nimport { cleanupPendingSpansForTransport, completeSpanWithResults, storeSpanForRequest } from './correlation';\nimport { captureError } from './errorCapture';\nimport {\n buildClientAttributesFromInfo,\n extractSessionDataFromInitializeRequest,\n extractSessionDataFromInitializeResponse,\n} from './sessionExtraction';\nimport {\n cleanupSessionDataForTransport,\n storeSessionDataForTransport,\n updateSessionDataForTransport,\n} from './sessionManagement';\nimport { buildMcpServerSpanConfig, createMcpNotificationSpan, createMcpOutgoingNotificationSpan } from './spans';\nimport type { ExtraHandlerData, MCPTransport, ResolvedMcpOptions, SessionData } from './types';\nimport { isJsonRpcNotification, isJsonRpcRequest, isJsonRpcResponse, isValidContentItem } from './validation';\n\n/**\n * Wraps transport.onmessage to create spans for incoming messages.\n * For \"initialize\" requests, extracts and stores client info and protocol version\n * in the session data for the transport.\n * @param transport - MCP transport instance to wrap\n * @param options - Resolved MCP options\n */\nexport function wrapTransportOnMessage(transport: MCPTransport, options: ResolvedMcpOptions): void {\n if (transport.onmessage) {\n fill(transport, 'onmessage', originalOnMessage => {\n return function (this: MCPTransport, message: unknown, extra?: unknown) {\n if (isJsonRpcRequest(message)) {\n const isInitialize = message.method === 'initialize';\n let initSessionData: SessionData | undefined;\n\n if (isInitialize) {\n try {\n initSessionData = extractSessionDataFromInitializeRequest(message);\n storeSessionDataForTransport(transport, initSessionData);\n } catch {\n // noop\n }\n }\n\n const isolationScope = getIsolationScope().clone();\n\n return withIsolationScope(isolationScope, () => {\n const spanConfig = buildMcpServerSpanConfig(message, transport, extra as ExtraHandlerData, options);\n const span = startInactiveSpan(spanConfig);\n\n // For initialize requests, add client info directly to span (works even for stateless transports)\n if (isInitialize && initSessionData) {\n span.setAttributes({\n ...buildClientAttributesFromInfo(initSessionData.clientInfo),\n ...(initSessionData.protocolVersion && {\n [MCP_PROTOCOL_VERSION_ATTRIBUTE]: initSessionData.protocolVersion,\n }),\n });\n }\n\n storeSpanForRequest(transport, message.id, span, message.method);\n\n return withActiveSpan(span, () => {\n return (originalOnMessage as (...args: unknown[]) => unknown).call(this, message, extra);\n });\n });\n }\n\n if (isJsonRpcNotification(message)) {\n return createMcpNotificationSpan(message, transport, extra as ExtraHandlerData, options, () => {\n return (originalOnMessage as (...args: unknown[]) => unknown).call(this, message, extra);\n });\n }\n\n return (originalOnMessage as (...args: unknown[]) => unknown).call(this, message, extra);\n };\n });\n }\n}\n\n/**\n * Wraps transport.send to handle outgoing messages and response correlation.\n * For \"initialize\" responses, extracts and stores protocol version and server info\n * in the session data for the transport.\n * @param transport - MCP transport instance to wrap\n * @param options - Resolved MCP options\n */\nexport function wrapTransportSend(transport: MCPTransport, options: ResolvedMcpOptions): void {\n if (transport.send) {\n fill(transport, 'send', originalSend => {\n return async function (this: MCPTransport, ...args: unknown[]) {\n const [message] = args;\n\n if (isJsonRpcNotification(message)) {\n return createMcpOutgoingNotificationSpan(message, transport, options, () => {\n return (originalSend as (...args: unknown[]) => unknown).call(this, ...args);\n });\n }\n\n if (isJsonRpcResponse(message)) {\n if (message.id !== null && message.id !== undefined) {\n if (message.error) {\n captureJsonRpcErrorResponse(message.error);\n }\n\n if (isValidContentItem(message.result)) {\n if (message.result.protocolVersion || message.result.serverInfo) {\n try {\n const serverData = extractSessionDataFromInitializeResponse(message.result);\n updateSessionDataForTransport(transport, serverData);\n } catch {\n // noop\n }\n }\n }\n\n completeSpanWithResults(transport, message.id, message.result, options, !!message.error);\n }\n }\n\n return (originalSend as (...args: unknown[]) => unknown).call(this, ...args);\n };\n });\n }\n}\n\n/**\n * Wraps transport.onclose to clean up pending spans for this transport only\n * @param transport - MCP transport instance to wrap\n */\nexport function wrapTransportOnClose(transport: MCPTransport): void {\n if (transport.onclose) {\n fill(transport, 'onclose', originalOnClose => {\n return function (this: MCPTransport, ...args: unknown[]) {\n cleanupPendingSpansForTransport(transport);\n cleanupSessionDataForTransport(transport);\n return (originalOnClose as (...args: unknown[]) => unknown).call(this, ...args);\n };\n });\n }\n}\n\n/**\n * Wraps transport error handlers to capture connection errors\n * @param transport - MCP transport instance to wrap\n */\nexport function wrapTransportError(transport: MCPTransport): void {\n if (transport.onerror) {\n fill(transport, 'onerror', (originalOnError: (error: Error) => void) => {\n return function (this: MCPTransport, error: Error) {\n captureTransportError(error);\n return originalOnError.call(this, error);\n };\n });\n }\n}\n\n/**\n * Captures JSON-RPC error responses for server-side errors.\n * @see https://www.jsonrpc.org/specification#error_object\n * @internal\n * @param errorResponse - JSON-RPC error response\n */\nfunction captureJsonRpcErrorResponse(errorResponse: unknown): void {\n try {\n if (errorResponse && typeof errorResponse === 'object' && 'code' in errorResponse && 'message' in errorResponse) {\n const jsonRpcError = errorResponse as { code: number; message: string; data?: unknown };\n\n const isServerError =\n jsonRpcError.code === -32603 || (jsonRpcError.code >= -32099 && jsonRpcError.code <= -32000);\n\n if (isServerError) {\n const error = new Error(jsonRpcError.message);\n error.name = `JsonRpcError_${jsonRpcError.code}`;\n\n captureError(error, 'protocol');\n }\n }\n } catch {\n // noop\n }\n}\n\n/**\n * Captures transport connection errors\n * @internal\n * @param error - Transport error\n */\nfunction captureTransportError(error: Error): void {\n try {\n captureError(error, 'transport');\n } catch {\n // noop\n }\n}\n"],"names":["fill","isJsonRpcRequest","extractSessionDataFromInitializeRequest","storeSessionDataForTransport","getIsolationScope","withIsolationScope","buildMcpServerSpanConfig","startInactiveSpan","buildClientAttributesFromInfo","MCP_PROTOCOL_VERSION_ATTRIBUTE","storeSpanForRequest","withActiveSpan","isJsonRpcNotification","createMcpNotificationSpan","createMcpOutgoingNotificationSpan","isJsonRpcResponse","isValidContentItem","extractSessionDataFromInitializeResponse","updateSessionDataForTransport","completeSpanWithResults","cleanupPendingSpansForTransport","cleanupSessionDataForTransport","captureError"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,sBAAsB,CAAC,SAAS,EAAgB,OAAO,EAA4B;AACnG,EAAE,IAAI,SAAS,CAAC,SAAS,EAAE;AAC3B,IAAIA,WAAI,CAAC,SAAS,EAAE,WAAW,EAAE,qBAAqB;AACtD,MAAM,OAAO,WAA8B,OAAO,EAAW,KAAK,EAAY;AAC9E,QAAQ,IAAIC,2BAAgB,CAAC,OAAO,CAAC,EAAE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AC;AACpC,QAAQ,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;AAChD,MAAM,CAAC;AACP,IAAI,CAAC,CAAC;AACN,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,2BAA2B,CAAC,aAAa,EAAiB;AACnE,EAAE,IAAI;AACN,IAAI,IAAI,aAAA,IAAiB,OAAO,kBAAkB,QAAA,IAAY,MAAA,IAAU,aAAA,IAAiB,SAAA,IAAa,aAAa,EAAE;AACrH,MAAM,MAAM,YAAA,GAAe,aAAA;;AAE3B,MAAM,MAAM,aAAA;AACZ,QAAQ,YAAY,CAAC,IAAA,KAAS,CAAC,KAAA,KAAU,YAAY,CAAC,QAAQ,CAAC,SAAS,YAAY,CAAC,IAAA,IAAQ,CAAC,KAAK,CAAC;;AAEpG,MAAM,IAAI,aAAa,EAAE;AACzB,QAAQ,MAAM,QAAQ,IAAI,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC;AACrD,QAAQ,KAAK,CAAC,IAAA,GAAO,CAAC,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,CAAA;;AAEA,QAAAsB,yBAAA,CAAA,KAAA,EAAA,UAAA,CAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA,CAAA,CAAA,MAAA;AACA;AACA,EAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAA,qBAAA,CAAA,KAAA,EAAA;AACA,EAAA,IAAA;AACA,IAAAA,yBAAA,CAAA,KAAA,EAAA,WAAA,CAAA;AACA,EAAA,CAAA,CAAA,MAAA;AACA;AACA,EAAA;AACA;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestdata.js","sources":["../../../src/integrations/requestdata.ts"],"sourcesContent":["import { defineIntegration } from '../integration';\nimport
|
|
1
|
+
{"version":3,"file":"requestdata.js","sources":["../../../src/integrations/requestdata.ts"],"sourcesContent":["import { defineIntegration } from '../integration';\nimport type { Event } from '../types-hoist/event';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport type { RequestEventData } from '../types-hoist/request';\nimport { parseCookie } from '../utils/cookie';\nimport { getClientIPAddress, ipHeaderNames } from '../vendor/getIpAddress';\n\ninterface RequestDataIncludeOptions {\n cookies?: boolean;\n data?: boolean;\n headers?: boolean;\n ip?: boolean;\n query_string?: boolean;\n url?: boolean;\n}\n\ntype RequestDataIntegrationOptions = {\n /**\n * Controls what data is pulled from the request and added to the event.\n */\n include?: RequestDataIncludeOptions;\n};\n\n// TODO(v11): Change defaults based on `sendDefaultPii`\nconst DEFAULT_INCLUDE: RequestDataIncludeOptions = {\n cookies: true,\n data: true,\n headers: true,\n query_string: true,\n url: true,\n};\n\nconst INTEGRATION_NAME = 'RequestData';\n\nconst _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) => {\n const include = {\n ...DEFAULT_INCLUDE,\n ...options.include,\n };\n\n return {\n name: INTEGRATION_NAME,\n processEvent(event, _hint, client) {\n const { sdkProcessingMetadata = {} } = event;\n const { normalizedRequest, ipAddress } = sdkProcessingMetadata;\n\n const includeWithDefaultPiiApplied: RequestDataIncludeOptions = {\n ...include,\n ip: include.ip ?? client.getOptions().sendDefaultPii,\n };\n\n if (normalizedRequest) {\n addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress }, includeWithDefaultPiiApplied);\n }\n\n return event;\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core`\n * so it can be used in cross-platform SDKs like `@sentry/nextjs`.\n */\nexport const requestDataIntegration = defineIntegration(_requestDataIntegration);\n\n/**\n * Add already normalized request data to an event.\n * This mutates the passed in event.\n */\nfunction addNormalizedRequestDataToEvent(\n event: Event,\n req: RequestEventData,\n // Data that should not go into `event.request` but is somehow related to requests\n additionalData: { ipAddress?: string },\n include: RequestDataIncludeOptions,\n): void {\n event.request = {\n ...event.request,\n ...extractNormalizedRequestData(req, include),\n };\n\n if (include.ip) {\n const ip = (req.headers && getClientIPAddress(req.headers)) || additionalData.ipAddress;\n if (ip) {\n event.user = {\n ...event.user,\n ip_address: ip,\n };\n }\n }\n}\n\nfunction extractNormalizedRequestData(\n normalizedRequest: RequestEventData,\n include: RequestDataIncludeOptions,\n): RequestEventData {\n const requestData: RequestEventData = {};\n const headers = { ...normalizedRequest.headers };\n\n if (include.headers) {\n requestData.headers = headers;\n\n // Remove the Cookie header in case cookie data should not be included in the event\n if (!include.cookies) {\n delete (headers as { cookie?: string }).cookie;\n }\n\n // Remove IP headers in case IP data should not be included in the event\n if (!include.ip) {\n ipHeaderNames.forEach(ipHeaderName => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete (headers as Record<string, unknown>)[ipHeaderName];\n });\n }\n }\n\n requestData.method = normalizedRequest.method;\n\n if (include.url) {\n requestData.url = normalizedRequest.url;\n }\n\n if (include.cookies) {\n const cookies = normalizedRequest.cookies || (headers?.cookie ? parseCookie(headers.cookie) : undefined);\n requestData.cookies = cookies || {};\n }\n\n if (include.query_string) {\n requestData.query_string = normalizedRequest.query_string;\n }\n\n if (include.data) {\n requestData.data = normalizedRequest.data;\n }\n\n return requestData;\n}\n"],"names":["defineIntegration","getClientIPAddress","ipHeaderNames","parseCookie"],"mappings":";;;;;;AAuBA;AACA,MAAM,eAAe,GAA8B;AACnD,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,IAAI,EAAE,IAAI;AACZ,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,YAAY,EAAE,IAAI;AACpB,EAAE,GAAG,EAAE,IAAI;AACX,CAAC;;AAED,MAAM,gBAAA,GAAmB,aAAa;;AAEtC,MAAM,uBAAA,IAA2B,CAAC,OAAO,GAAkC,EAAE,KAAK;AAClF,EAAE,MAAM,UAAU;AAClB,IAAI,GAAG,eAAe;AACtB,IAAI,GAAG,OAAO,CAAC,OAAO;AACtB,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B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}
|
|
@@ -30,10 +30,12 @@ function captureSpan(span, client) {
|
|
|
30
30
|
|
|
31
31
|
if (spanJSON.is_segment) {
|
|
32
32
|
// Allow hook subscribers to mutate the segment span JSON
|
|
33
|
+
// This also invokes the `processSegmentSpan` hook of all integrations
|
|
33
34
|
client.emit('processSegmentSpan', spanJSON);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
//
|
|
37
|
+
// This allows hook subscribers to mutate the span JSON
|
|
38
|
+
// This also invokes the `processSpan` hook of all integrations
|
|
37
39
|
client.emit('processSpan', spanJSON);
|
|
38
40
|
|
|
39
41
|
const { beforeSendSpan: beforeSendSpan$1 } = client.getOptions();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captureSpan.js","sources":["../../../../src/tracing/spans/captureSpan.ts"],"sourcesContent":["import type { RawAttributes } from '../../attributes';\nimport type { Client } from '../../client';\nimport type { ScopeData } from '../../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT,\n SEMANTIC_ATTRIBUTE_SENTRY_RELEASE,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_USER_EMAIL,\n SEMANTIC_ATTRIBUTE_USER_ID,\n SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,\n SEMANTIC_ATTRIBUTE_USER_USERNAME,\n} from '../../semanticAttributes';\nimport type { SerializedStreamedSpan, Span, StreamedSpanJSON } from '../../types-hoist/span';\nimport { getCombinedScopeData } from '../../utils/scopeData';\nimport {\n INTERNAL_getSegmentSpan,\n showSpanDropWarning,\n spanToStreamedSpanJSON,\n streamedSpanJsonToSerializedSpan,\n} from '../../utils/spanUtils';\nimport { getCapturedScopesOnSpan } from '../utils';\nimport { isStreamedBeforeSendSpanCallback } from './beforeSendSpan';\n\nexport type SerializedStreamedSpanWithSegmentSpan = SerializedStreamedSpan & {\n _segmentSpan: Span;\n};\n\n/**\n * Captures a span and returns a JSON representation to be enqueued for sending.\n *\n * IMPORTANT: This function converts the span to JSON immediately to avoid writing\n * to an already-ended OTel span instance (which is blocked by the OTel Span class).\n *\n * @returns the final serialized span with a reference to its segment span. This reference\n * is needed later on to compute the DSC for the span envelope.\n */\nexport function captureSpan(span: Span, client: Client): SerializedStreamedSpanWithSegmentSpan {\n // Convert to JSON FIRST - we cannot write to an already-ended span\n const spanJSON = spanToStreamedSpanJSON(span);\n\n const segmentSpan = INTERNAL_getSegmentSpan(span);\n const serializedSegmentSpan = spanToStreamedSpanJSON(segmentSpan);\n\n const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);\n\n const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);\n\n applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);\n\n if (spanJSON.is_segment) {\n applyScopeToSegmentSpan(spanJSON, finalScopeData);\n // Allow hook subscribers to mutate the segment span JSON\n client.emit('processSegmentSpan', spanJSON);\n }\n\n //
|
|
1
|
+
{"version":3,"file":"captureSpan.js","sources":["../../../../src/tracing/spans/captureSpan.ts"],"sourcesContent":["import type { RawAttributes } from '../../attributes';\nimport type { Client } from '../../client';\nimport type { ScopeData } from '../../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT,\n SEMANTIC_ATTRIBUTE_SENTRY_RELEASE,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_USER_EMAIL,\n SEMANTIC_ATTRIBUTE_USER_ID,\n SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,\n SEMANTIC_ATTRIBUTE_USER_USERNAME,\n} from '../../semanticAttributes';\nimport type { SerializedStreamedSpan, Span, StreamedSpanJSON } from '../../types-hoist/span';\nimport { getCombinedScopeData } from '../../utils/scopeData';\nimport {\n INTERNAL_getSegmentSpan,\n showSpanDropWarning,\n spanToStreamedSpanJSON,\n streamedSpanJsonToSerializedSpan,\n} from '../../utils/spanUtils';\nimport { getCapturedScopesOnSpan } from '../utils';\nimport { isStreamedBeforeSendSpanCallback } from './beforeSendSpan';\n\nexport type SerializedStreamedSpanWithSegmentSpan = SerializedStreamedSpan & {\n _segmentSpan: Span;\n};\n\n/**\n * Captures a span and returns a JSON representation to be enqueued for sending.\n *\n * IMPORTANT: This function converts the span to JSON immediately to avoid writing\n * to an already-ended OTel span instance (which is blocked by the OTel Span class).\n *\n * @returns the final serialized span with a reference to its segment span. This reference\n * is needed later on to compute the DSC for the span envelope.\n */\nexport function captureSpan(span: Span, client: Client): SerializedStreamedSpanWithSegmentSpan {\n // Convert to JSON FIRST - we cannot write to an already-ended span\n const spanJSON = spanToStreamedSpanJSON(span);\n\n const segmentSpan = INTERNAL_getSegmentSpan(span);\n const serializedSegmentSpan = spanToStreamedSpanJSON(segmentSpan);\n\n const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);\n\n const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);\n\n applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);\n\n if (spanJSON.is_segment) {\n applyScopeToSegmentSpan(spanJSON, finalScopeData);\n // Allow hook subscribers to mutate the segment span JSON\n // This also invokes the `processSegmentSpan` hook of all integrations\n client.emit('processSegmentSpan', spanJSON);\n }\n\n // This allows hook subscribers to mutate the span JSON\n // This also invokes the `processSpan` hook of all integrations\n client.emit('processSpan', spanJSON);\n\n const { beforeSendSpan } = client.getOptions();\n const processedSpan =\n beforeSendSpan && isStreamedBeforeSendSpanCallback(beforeSendSpan)\n ? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)\n : spanJSON;\n\n // Backfill sentry.span.source from sentry.source. Only `sentry.span.source` is respected by Sentry.\n // TODO(v11): Remove this backfill once we renamed SEMANTIC_ATTRIBUTE_SENTRY_SOURCE to sentry.span.source\n const spanNameSource = processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n if (spanNameSource) {\n safeSetSpanJSONAttributes(processedSpan, {\n // Purposefully not using a constant defined here like in other attributes:\n // This will be the name for SEMANTIC_ATTRIBUTE_SENTRY_SOURCE in v11\n 'sentry.span.source': spanNameSource,\n });\n }\n\n return {\n ...streamedSpanJsonToSerializedSpan(processedSpan),\n _segmentSpan: segmentSpan,\n };\n}\n\nfunction applyScopeToSegmentSpan(_segmentSpanJSON: StreamedSpanJSON, _scopeData: ScopeData): void {\n // TODO: Apply all scope and request data from auto instrumentation (contexts, request) to segment span\n // This will follow in a separate PR\n}\n\nfunction applyCommonSpanAttributes(\n spanJSON: StreamedSpanJSON,\n serializedSegmentSpan: StreamedSpanJSON,\n client: Client,\n scopeData: ScopeData,\n): void {\n const sdk = client.getSdkMetadata();\n const { release, environment, sendDefaultPii } = client.getOptions();\n\n // avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)\n safeSetSpanJSONAttributes(spanJSON, {\n [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,\n [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,\n ...(sendDefaultPii\n ? {\n [SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,\n [SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,\n [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,\n [SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,\n }\n : {}),\n ...scopeData.attributes,\n });\n}\n\n/**\n * Apply a user-provided beforeSendSpan callback to a span JSON.\n */\nexport function applyBeforeSendSpanCallback(\n span: StreamedSpanJSON,\n beforeSendSpan: (span: StreamedSpanJSON) => StreamedSpanJSON,\n): StreamedSpanJSON {\n const modifedSpan = beforeSendSpan(span);\n if (!modifedSpan) {\n showSpanDropWarning();\n return span;\n }\n return modifedSpan;\n}\n\n/**\n * Safely set attributes on a span JSON.\n * If an attribute already exists, it will not be overwritten.\n */\nexport function safeSetSpanJSONAttributes(\n spanJSON: StreamedSpanJSON,\n newAttributes: RawAttributes<Record<string, unknown>>,\n): void {\n const originalAttributes = spanJSON.attributes ?? (spanJSON.attributes = {});\n\n Object.entries(newAttributes).forEach(([key, value]) => {\n if (value != null && !(key in originalAttributes)) {\n originalAttributes[key] = value;\n }\n });\n}\n"],"names":["spanToStreamedSpanJSON","INTERNAL_getSegmentSpan","getCapturedScopesOnSpan","getCombinedScopeData","beforeSendSpan","isStreamedBeforeSendSpanCallback","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","streamedSpanJsonToSerializedSpan","SEMANTIC_ATTRIBUTE_SENTRY_RELEASE","SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT","SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME","SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID","SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME","SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION","SEMANTIC_ATTRIBUTE_USER_ID","SEMANTIC_ATTRIBUTE_USER_EMAIL","SEMANTIC_ATTRIBUTE_USER_IP_ADD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AAC,IAAI,CAAC;AAC1C,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAIC,6BAAmB,EAAE;AACzB,IAAI,OAAO,IAAI;AACf,EAAE;AACF,EAAE,OAAO,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACO,SAAS,yBAAyB;AACzC,EAAE,QAAQ;AACV,EAAE,aAAa;AACf,EAAQ;AACR,EAAE,MAAM,kBAAA,GAAqB,QAAQ,CAAC,UAAA,KAAe,QAAQ,CAAC,UAAA,GAAa,EAAE,CAAC;;AAE9E,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AAC1D,IAAI,IAAI,KAAA,IAAS,IAAA,IAAQ,EAAE,GAAA,IAAO,kBAAkB,CAAC,EAAE;AACvD,MAAM,kBAAkB,CAAC,GAAG,CAAA,GAAI,KAAK;AACrC,IAAI;AACJ,EAAE,CAAC,CAAC;AACJ;;;;;;"}
|
|
@@ -60,9 +60,10 @@ function startSpan(options, callback) {
|
|
|
60
60
|
return wrapper(() => {
|
|
61
61
|
const scope = currentScopes.getCurrentScope();
|
|
62
62
|
const parentSpan = getParentSpan(scope, customParentSpan);
|
|
63
|
+
const client = currentScopes.getClient();
|
|
63
64
|
|
|
64
|
-
const
|
|
65
|
-
const activeSpan =
|
|
65
|
+
const missingRequiredParent = options.onlyIfParent && !parentSpan;
|
|
66
|
+
const activeSpan = missingRequiredParent
|
|
66
67
|
? new sentryNonRecordingSpan.SentryNonRecordingSpan()
|
|
67
68
|
: createChildOrRootSpan({
|
|
68
69
|
parentSpan,
|
|
@@ -71,6 +72,10 @@ function startSpan(options, callback) {
|
|
|
71
72
|
scope,
|
|
72
73
|
});
|
|
73
74
|
|
|
75
|
+
if (missingRequiredParent) {
|
|
76
|
+
client?.recordDroppedEvent('no_parent_span', 'span');
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
// Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them
|
|
75
80
|
// and descendants are also non-recording. Ignored child spans don't need this because
|
|
76
81
|
// the parent span is already on scope.
|
|
@@ -124,8 +129,8 @@ function startSpanManual(options, callback) {
|
|
|
124
129
|
const scope = currentScopes.getCurrentScope();
|
|
125
130
|
const parentSpan = getParentSpan(scope, customParentSpan);
|
|
126
131
|
|
|
127
|
-
const
|
|
128
|
-
const activeSpan =
|
|
132
|
+
const missingRequiredParent = options.onlyIfParent && !parentSpan;
|
|
133
|
+
const activeSpan = missingRequiredParent
|
|
129
134
|
? new sentryNonRecordingSpan.SentryNonRecordingSpan()
|
|
130
135
|
: createChildOrRootSpan({
|
|
131
136
|
parentSpan,
|
|
@@ -134,6 +139,10 @@ function startSpanManual(options, callback) {
|
|
|
134
139
|
scope,
|
|
135
140
|
});
|
|
136
141
|
|
|
142
|
+
if (missingRequiredParent) {
|
|
143
|
+
currentScopes.getClient()?.recordDroppedEvent('no_parent_span', 'span');
|
|
144
|
+
}
|
|
145
|
+
|
|
137
146
|
// We don't set ignored child spans onto the scope because there likely is an active,
|
|
138
147
|
// unignored span on the scope already.
|
|
139
148
|
if (!_isIgnoredSpan(activeSpan) || !parentSpan) {
|
|
@@ -187,10 +196,12 @@ function startInactiveSpan(options) {
|
|
|
187
196
|
return wrapper(() => {
|
|
188
197
|
const scope = currentScopes.getCurrentScope();
|
|
189
198
|
const parentSpan = getParentSpan(scope, customParentSpan);
|
|
199
|
+
const client = currentScopes.getClient();
|
|
190
200
|
|
|
191
|
-
const
|
|
201
|
+
const missingRequiredParent = options.onlyIfParent && !parentSpan;
|
|
192
202
|
|
|
193
|
-
if (
|
|
203
|
+
if (missingRequiredParent) {
|
|
204
|
+
client?.recordDroppedEvent('no_parent_span', 'span');
|
|
194
205
|
return new sentryNonRecordingSpan.SentryNonRecordingSpan();
|
|
195
206
|
}
|
|
196
207
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sources":["../../../src/tracing/trace.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types-hoist/envelope';\nimport type { ClientOptions } from '../types-hoist/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types-hoist/span';\nimport type { StartSpanOptions } from '../types-hoist/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { shouldIgnoreSpan } from '../utils/should-ignore-span';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\nimport type { Client } from '../client';\n\nconst SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them\n // and descendants are also non-recording. Ignored child spans don't need this because\n // the parent span is already on scope.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // We don't set ignored child spans onto the scope because there likely is an active,\n // unignored span on the scope already.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n\n if (shouldSkipSpan) {\n return new SentryNonRecordingSpan();\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n if (!hasSpansEnabled()) {\n const span = new SentryNonRecordingSpan();\n\n // If this is a root span, we ensure to freeze a DSC\n // So we can have at least partial data here\n if (forceTransaction || !parentSpan) {\n const dsc = {\n sampled: 'false',\n sample_rate: '0',\n transaction: spanArguments.name,\n ...getDynamicSamplingContextFromSpan(span),\n } satisfies Partial<DynamicSamplingContext>;\n freezeDscOnSpan(span, dsc);\n }\n\n return span;\n }\n\n const client = getClient();\n if (_shouldIgnoreStreamedSpan(client, spanArguments)) {\n if (!_isTracingSuppressed(scope)) {\n // if tracing is actively suppressed (Sentry.suppressTracing(...)),\n // we don't want to record a client outcome for the ignored span\n client?.recordDroppedEvent('ignored', 'span');\n }\n\n return new SentryNonRecordingSpan({\n dropReason: 'ignored',\n traceId: parentSpan?.spanContext().traceId ?? scope.getPropagationContext().traceId,\n });\n }\n\n const isolationScope = getIsolationScope();\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(spanArguments: SentrySpanArguments, scope: Scope, parentSampled?: boolean): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const isTracingSuppressed = _isTracingSuppressed(scope);\n\n const [sampled, sampleRate, localSampleRateWasApplied] = isTracingSuppressed\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client && !isTracingSuppressed) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', hasSpanStreamingEnabled(client) ? 'span' : 'transaction');\n }\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(parentSpan: Span, scope: Scope, spanArguments: SentrySpanArguments): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const isTracingSuppressed = _isTracingSuppressed(scope);\n const sampled = isTracingSuppressed ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n const client = getClient();\n\n if (!client) {\n return childSpan;\n }\n\n if (hasSpanStreamingEnabled(client) && childSpan instanceof SentryNonRecordingSpan) {\n if (parentSpan instanceof SentryNonRecordingSpan && parentSpan.dropReason) {\n // We land here if the parent span was a segment span that was ignored (`ignoreSpans`).\n // In this case, the child was also ignored (see `sampled` above) but we need to\n // record a client outcome for the child.\n childSpan.dropReason = parentSpan.dropReason;\n client.recordDroppedEvent(parentSpan.dropReason, 'span');\n } else if (!isTracingSuppressed) {\n // Otherwise, the child is not sampled due to sampling of the parent span,\n // hence we record a sample_rate client outcome for the child.\n childSpan.dropReason = 'sample_rate';\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n client.emit('afterSpanEnd', childSpan);\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n\n/* Checks if `ignoreSpans` applies (extracted for bundle size)*/\nfunction _shouldIgnoreStreamedSpan(client: Client | undefined, spanArguments: SentrySpanArguments): boolean {\n const ignoreSpans = client?.getOptions().ignoreSpans;\n\n if (!client || !hasSpanStreamingEnabled(client) || !ignoreSpans?.length) {\n return false;\n }\n\n return shouldIgnoreSpan(\n {\n description: spanArguments.name || '',\n op: spanArguments.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] || spanArguments.op,\n },\n ignoreSpans,\n );\n}\n\nfunction _isIgnoredSpan(span: Span): span is SentryNonRecordingSpan {\n return span instanceof SentryNonRecordingSpan && span.dropReason === 'ignored';\n}\n\nfunction _isTracingSuppressed(scope: Scope): boolean {\n return scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] === true;\n}\n"],"names":["withScope","getCurrentScope","SentryNonRecordingSpan","_setSpanForScope","handleCallbackErrors","spanToJSON","SPAN_STATUS_ERROR","carrier","getMainCarrier","getAsyncContextStrategy","baggage","getClient","baggageHeaderToDynamicSamplingContext","shouldContinueTrace","propagationContextFromHeaders","generateTraceId","safeMathRandom","DEBUG_BUILD","debug","hasSpansEnabled","getDynamicSamplingContextFromSpan","freezeDscOnSpan","getIsolationScope","addChildSpanToSpan","spanIsSampled","logSpanStart","setCapturedScopesOnSpan","spanTimeInputToSeconds","sampleSpan","parseSampleRate","SentrySpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","hasSpanStreamingEnabled","_getSpanForScope","getRootSpan","shouldIgnoreSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AAsCA,MAAM,oBAAA,GAAuB,6BAA6B;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAI,OAAO,EAAoB,QAAQ,EAAwB;AACxF,EAAE,MAAM,GAAA,GAAM,MAAM,EAAE;AACtB,EAAE,IAAI,GAAG,CAAC,SAAS,EAAE;AACrB,IAAI,OAAO,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC;AAC3C,EAAE;;AAEF,EAAE,MAAM,aAAA,GAAgB,wBAAwB,CAAC,OAAO,CAAC;AACzD,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAA,EAAY,GAAI,OAAO;;AAExF;AACA;AACA,EAAE,MAAM,iBAAA,GAAoB,WAAW,EAAE,KAAK,EAAE;;AAEhD,EAAE,OAAOA,uBAAS,CAAC,iBAAiB,EAAE,MAAM;AAC5C;AACA,IAAI,MAAM,OAAA,GAAU,oBAAoB,CAAI,gBAAg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A;AACA,MAAA,EAAA,EAAA,aAAA,CAAA,UAAA,GAAAC,+CAAA,CAAA,IAAA,aAAA,CAAA,EAAA;AACA,KAAA;AACA,IAAA,WAAA;AACA,GAAA;AACA;;AAEA,SAAA,cAAA,CAAA,IAAA,EAAA;AACA,EAAA,OAAA,IAAA,YAAAnC,6CAAA,IAAA,IAAA,CAAA,UAAA,KAAA,SAAA;AACA;;AAEA,SAAA,oBAAA,CAAA,KAAA,EAAA;AACA,EAAA,OAAA,KAAA,CAAA,YAAA,EAAA,CAAA,qBAAA,CAAA,oBAAA,CAAA,KAAA,IAAA;AACA;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"trace.js","sources":["../../../src/tracing/trace.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types-hoist/envelope';\nimport type { ClientOptions } from '../types-hoist/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types-hoist/span';\nimport type { StartSpanOptions } from '../types-hoist/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { shouldIgnoreSpan } from '../utils/should-ignore-span';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\nimport type { Client } from '../client';\n\nconst SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n if (missingRequiredParent) {\n client?.recordDroppedEvent('no_parent_span', 'span');\n }\n\n // Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them\n // and descendants are also non-recording. Ignored child spans don't need this because\n // the parent span is already on scope.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n if (missingRequiredParent) {\n getClient()?.recordDroppedEvent('no_parent_span', 'span');\n }\n\n // We don't set ignored child spans onto the scope because there likely is an active,\n // unignored span on the scope already.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n\n if (missingRequiredParent) {\n client?.recordDroppedEvent('no_parent_span', 'span');\n return new SentryNonRecordingSpan();\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n if (!hasSpansEnabled()) {\n const span = new SentryNonRecordingSpan();\n\n // If this is a root span, we ensure to freeze a DSC\n // So we can have at least partial data here\n if (forceTransaction || !parentSpan) {\n const dsc = {\n sampled: 'false',\n sample_rate: '0',\n transaction: spanArguments.name,\n ...getDynamicSamplingContextFromSpan(span),\n } satisfies Partial<DynamicSamplingContext>;\n freezeDscOnSpan(span, dsc);\n }\n\n return span;\n }\n\n const client = getClient();\n if (_shouldIgnoreStreamedSpan(client, spanArguments)) {\n if (!_isTracingSuppressed(scope)) {\n // if tracing is actively suppressed (Sentry.suppressTracing(...)),\n // we don't want to record a client outcome for the ignored span\n client?.recordDroppedEvent('ignored', 'span');\n }\n\n return new SentryNonRecordingSpan({\n dropReason: 'ignored',\n traceId: parentSpan?.spanContext().traceId ?? scope.getPropagationContext().traceId,\n });\n }\n\n const isolationScope = getIsolationScope();\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(spanArguments: SentrySpanArguments, scope: Scope, parentSampled?: boolean): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const isTracingSuppressed = _isTracingSuppressed(scope);\n\n const [sampled, sampleRate, localSampleRateWasApplied] = isTracingSuppressed\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client && !isTracingSuppressed) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', hasSpanStreamingEnabled(client) ? 'span' : 'transaction');\n }\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(parentSpan: Span, scope: Scope, spanArguments: SentrySpanArguments): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const isTracingSuppressed = _isTracingSuppressed(scope);\n const sampled = isTracingSuppressed ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n const client = getClient();\n\n if (!client) {\n return childSpan;\n }\n\n if (hasSpanStreamingEnabled(client) && childSpan instanceof SentryNonRecordingSpan) {\n if (parentSpan instanceof SentryNonRecordingSpan && parentSpan.dropReason) {\n // We land here if the parent span was a segment span that was ignored (`ignoreSpans`).\n // In this case, the child was also ignored (see `sampled` above) but we need to\n // record a client outcome for the child.\n childSpan.dropReason = parentSpan.dropReason;\n client.recordDroppedEvent(parentSpan.dropReason, 'span');\n } else if (!isTracingSuppressed) {\n // Otherwise, the child is not sampled due to sampling of the parent span,\n // hence we record a sample_rate client outcome for the child.\n childSpan.dropReason = 'sample_rate';\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n client.emit('afterSpanEnd', childSpan);\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n\n/* Checks if `ignoreSpans` applies (extracted for bundle size)*/\nfunction _shouldIgnoreStreamedSpan(client: Client | undefined, spanArguments: SentrySpanArguments): boolean {\n const ignoreSpans = client?.getOptions().ignoreSpans;\n\n if (!client || !hasSpanStreamingEnabled(client) || !ignoreSpans?.length) {\n return false;\n }\n\n return shouldIgnoreSpan(\n {\n description: spanArguments.name || '',\n op: spanArguments.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] || spanArguments.op,\n },\n ignoreSpans,\n );\n}\n\nfunction _isIgnoredSpan(span: Span): span is SentryNonRecordingSpan {\n return span instanceof SentryNonRecordingSpan && span.dropReason === 'ignored';\n}\n\nfunction _isTracingSuppressed(scope: Scope): boolean {\n return scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] === true;\n}\n"],"names":["withScope","getCurrentScope","getClient","SentryNonRecordingSpan","_setSpanForScope","handleCallbackErrors","spanToJSON","SPAN_STATUS_ERROR","carrier","getMainCarrier","getAsyncContextStrategy","baggage","baggageHeaderToDynamicSamplingContext","shouldContinueTrace","propagationContextFromHeaders","generateTraceId","safeMathRandom","DEBUG_BUILD","debug","hasSpansEnabled","getDynamicSamplingContextFromSpan","freezeDscOnSpan","getIsolationScope","addChildSpanToSpan","spanIsSampled","logSpanStart","setCapturedScopesOnSpan","spanTimeInputToSeconds","sampleSpan","parseSampleRate","SentrySpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","hasSpanStreamingEnabled","_getSpanForScope","getRootSpan","shouldIgnoreSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AAsCA,MAAM,oBAAA,GAAuB,6BAA6B;;A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,SAAA;AACA;;AAEA,SAAA,oBAAA,CAAA,KAAA,EAAA;AACA,EAAA,OAAA,KAAA,CAAA,YAAA,EAAA,CAAA,qBAAA,CAAA,oBAAA,CAAA,KAAA,IAAA;AACA;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
// This is a magic string replaced by rollup
|
|
4
4
|
|
|
5
|
-
const SDK_VERSION = "10.
|
|
5
|
+
const SDK_VERSION = "10.50.0" ;
|
|
6
6
|
|
|
7
7
|
exports.SDK_VERSION = SDK_VERSION;
|
|
8
8
|
//# sourceMappingURL=version.js.map
|