@sentry/opentelemetry 10.60.0 → 10.62.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/index.browser.js +1 -2
- package/build/cjs/index.browser.js.map +1 -1
- package/build/cjs/index.js +1 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/{resource-DEULI4zI.js → resource-DuZKnQnC.js} +27 -14
- package/build/cjs/resource-DuZKnQnC.js.map +1 -0
- package/build/esm/index.browser.js +1 -2
- package/build/esm/index.browser.js.map +1 -1
- package/build/esm/index.js +2 -3
- package/build/esm/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/{resource-PMlHXvcP.js → resource-DazDAxCp.js} +20 -7
- package/build/esm/resource-DazDAxCp.js.map +1 -0
- package/build/types/asyncContextStrategy.d.ts.map +1 -1
- package/build/types/spanProcessor.d.ts.map +1 -1
- package/package.json +2 -12
- package/build/cjs/debug-build-CQngOfDt.js +0 -4
- package/build/cjs/debug-build-CQngOfDt.js.map +0 -1
- package/build/cjs/resource-DEULI4zI.js.map +0 -1
- package/build/cjs/tracingChannel.js +0 -32
- package/build/cjs/tracingChannel.js.map +0 -1
- package/build/esm/debug-build-B98wrZ1j.js +0 -4
- package/build/esm/debug-build-B98wrZ1j.js.map +0 -1
- package/build/esm/resource-PMlHXvcP.js.map +0 -1
- package/build/esm/tracingChannel.js +0 -30
- package/build/esm/tracingChannel.js.map +0 -1
- package/build/types/tracingChannel.d.ts +0 -38
- package/build/types/tracingChannel.d.ts.map +0 -1
- package/build/types-ts3.8/tracingChannel.d.ts +0 -38
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
|
-
const resource = require('./resource-
|
|
4
|
+
const resource = require('./resource-DuZKnQnC.js');
|
|
5
5
|
require('@opentelemetry/api');
|
|
6
6
|
require('@sentry/conventions/attributes');
|
|
7
7
|
require('@opentelemetry/core');
|
|
8
|
-
require('./debug-build-CQngOfDt.js');
|
|
9
8
|
require('@opentelemetry/sdk-trace-base');
|
|
10
9
|
|
|
11
10
|
class SentryAsyncLocalStorageContextManager {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.js","sources":["../../src/index.browser.ts"],"sourcesContent":["import { consoleSandbox } from '@sentry/core';\n\nexport * from './exports';\n\n// Stubs for node-specific exports\nexport class SentryAsyncLocalStorageContextManager {\n public constructor() {\n consoleSandbox(() => {\n // oxlint-disable-next-line no-console\n console.error('SentryAsyncLocalStorageContextManager is not supported in the browser');\n });\n }\n}\n\nexport type AsyncLocalStorageLookup = {\n asyncLocalStorage: unknown;\n contextSymbol: symbol;\n};\n"],"names":["consoleSandbox"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.browser.js","sources":["../../src/index.browser.ts"],"sourcesContent":["import { consoleSandbox } from '@sentry/core';\n\nexport * from './exports';\n\n// Stubs for node-specific exports\nexport class SentryAsyncLocalStorageContextManager {\n public constructor() {\n consoleSandbox(() => {\n // oxlint-disable-next-line no-console\n console.error('SentryAsyncLocalStorageContextManager is not supported in the browser');\n });\n }\n}\n\nexport type AsyncLocalStorageLookup = {\n asyncLocalStorage: unknown;\n contextSymbol: symbol;\n};\n"],"names":["consoleSandbox"],"mappings":";;;;;;;;;AAKO,MAAM,qCAAA,CAAsC;AAAA,EAC1C,WAAA,GAAc;AACnB,IAAAA,mBAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,MAAM,uEAAuE,CAAA;AAAA,IACvF,CAAC,CAAA;AAAA,EACH;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/cjs/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const resource = require('./resource-
|
|
3
|
+
const resource = require('./resource-DuZKnQnC.js');
|
|
4
4
|
const core = require('@sentry/core');
|
|
5
5
|
const api = require('@opentelemetry/api');
|
|
6
6
|
const node_async_hooks = require('node:async_hooks');
|
|
7
7
|
const node_events = require('node:events');
|
|
8
8
|
require('@sentry/conventions/attributes');
|
|
9
9
|
require('@opentelemetry/core');
|
|
10
|
-
require('./debug-build-CQngOfDt.js');
|
|
11
10
|
require('@opentelemetry/sdk-trace-base');
|
|
12
11
|
|
|
13
12
|
const ADD_LISTENER_METHODS = ["addListener", "on", "once", "prependListener", "prependOnceListener"];
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/asyncLocalStorageContextManager.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * This implementation follows the behavior of OpenTelemetry’s `@opentelemetry/context-async-hooks`\n * package, combining logic that upstream splits across:\n * - https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts\n * - https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts\n * It is a single-class re-implementation for Sentry (not a verbatim copy of those files).\n */\n\nimport type { Context, ContextManager } from '@opentelemetry/api';\nimport { ROOT_CONTEXT } from '@opentelemetry/api';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { EventEmitter } from 'node:events';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from './constants';\nimport type { AsyncLocalStorageLookup } from './contextManager';\nimport { buildContextWithSentryScopes } from './utils/buildContextWithSentryScopes';\nimport { setIsSetup } from './utils/setupCheck';\n\ntype ListenerFn = (...args: unknown[]) => unknown;\n\n/**\n * Per-event map from user listeners to context-bound listeners.\n */\ntype PatchMap = Record<string, WeakMap<ListenerFn, ListenerFn>>;\n\nconst ADD_LISTENER_METHODS = ['addListener', 'on', 'once', 'prependListener', 'prependOnceListener'] as const;\n\n/**\n * OpenTelemetry-compatible context manager using Node.js `AsyncLocalStorage`.\n * Semantics match `@opentelemetry/context-async-hooks` (function `bind` + `EventEmitter` patching).\n */\nexport class SentryAsyncLocalStorageContextManager implements ContextManager {\n protected readonly _asyncLocalStorage = new AsyncLocalStorage<Context>();\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n\n public constructor() {\n setIsSetup('SentryContextManager');\n }\n\n public active(): Context {\n return this._asyncLocalStorage.getStore() ?? ROOT_CONTEXT;\n }\n\n public with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n const ctx2 = buildContextWithSentryScopes(context, this.active());\n const cb = thisArg == null ? fn : fn.bind(thisArg);\n return this._asyncLocalStorage.run(ctx2, cb as never, ...args);\n }\n\n public enable(): this {\n return this;\n }\n\n public disable(): this {\n this._asyncLocalStorage.disable();\n return this;\n }\n\n public bind<T>(context: Context, target: T): T {\n if (target instanceof EventEmitter) {\n return this._bindEventEmitter(context, target);\n }\n if (typeof target === 'function') {\n return this._bindFunction(context, target as unknown as ListenerFn) as T;\n }\n return target;\n }\n\n /**\n * Gets underlying AsyncLocalStorage and symbol to allow lookup of scope.\n * This is Sentry-specific.\n */\n public getAsyncLocalStorageLookup(): AsyncLocalStorageLookup {\n return {\n asyncLocalStorage: this._asyncLocalStorage,\n contextSymbol: SENTRY_SCOPES_CONTEXT_KEY,\n };\n }\n\n private _bindFunction(context: Context, target: ListenerFn): ListenerFn {\n const managerWith = this.with.bind(this);\n const contextWrapper = function (this: never, ...args: unknown[]) {\n return managerWith(context, () => target.apply(this, args));\n };\n Object.defineProperty(contextWrapper, 'length', {\n enumerable: false,\n configurable: true,\n writable: false,\n value: target.length,\n });\n return contextWrapper;\n }\n\n private _bindEventEmitter<T extends EventEmitter>(context: Context, ee: T): T {\n if (this._getPatchMap(ee) !== undefined) {\n return ee;\n }\n this._createPatchMap(ee);\n\n for (const methodName of ADD_LISTENER_METHODS) {\n if (ee[methodName] === undefined) continue;\n ee[methodName] = this._patchAddListener(\n ee,\n ee[methodName] as unknown as (...args: unknown[]) => unknown,\n context,\n );\n }\n if (typeof ee.removeListener === 'function') {\n // oxlint-disable-next-line @typescript-eslint/unbound-method -- patched like upstream OTel context manager\n ee.removeListener = this._patchRemoveListener(ee, ee.removeListener as (...args: unknown[]) => unknown);\n }\n if (typeof ee.off === 'function') {\n // oxlint-disable-next-line @typescript-eslint/unbound-method\n ee.off = this._patchRemoveListener(ee, ee.off as (...args: unknown[]) => unknown);\n }\n if (typeof ee.removeAllListeners === 'function') {\n ee.removeAllListeners = this._patchRemoveAllListeners(\n ee,\n // oxlint-disable-next-line @typescript-eslint/unbound-method\n ee.removeAllListeners as (...args: unknown[]) => unknown,\n );\n }\n return ee;\n }\n\n private _patchRemoveListener(ee: EventEmitter, original: (...args: unknown[]) => unknown) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event: string, listener: ListenerFn) {\n const events = contextManager._getPatchMap(ee)?.[event];\n if (events === undefined) {\n return original.call(this, event, listener);\n }\n const patchedListener = events.get(listener);\n return original.call(this, event, patchedListener || listener);\n };\n }\n\n private _patchRemoveAllListeners(ee: EventEmitter, original: (...args: unknown[]) => unknown) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event?: string) {\n const map = contextManager._getPatchMap(ee);\n if (map !== undefined) {\n if (arguments.length === 0) {\n contextManager._createPatchMap(ee);\n } else if (event !== undefined && map[event] !== undefined) {\n // oxlint-disable-next-line @typescript-eslint/no-dynamic-delete -- event-keyed listener map\n delete map[event];\n }\n }\n return original.apply(this, arguments);\n };\n }\n\n private _patchAddListener(ee: EventEmitter, original: (...args: unknown[]) => unknown, context: Context) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event: string, listener: ListenerFn) {\n if (contextManager._wrapped) {\n return original.call(this, event, listener);\n }\n let map = contextManager._getPatchMap(ee);\n if (map === undefined) {\n map = contextManager._createPatchMap(ee);\n }\n let listeners = map[event];\n if (listeners === undefined) {\n listeners = new WeakMap();\n map[event] = listeners;\n }\n const patchedListener = contextManager.bind(context, listener);\n listeners.set(listener, patchedListener);\n\n contextManager._wrapped = true;\n try {\n return original.call(this, event, patchedListener);\n } finally {\n contextManager._wrapped = false;\n }\n };\n }\n\n private _createPatchMap(ee: EventEmitter): PatchMap {\n const map = Object.create(null) as PatchMap;\n (ee as unknown as Record<symbol, PatchMap>)[this._kOtListeners] = map;\n return map;\n }\n\n private _getPatchMap(ee: EventEmitter): PatchMap | undefined {\n return (ee as unknown as Record<symbol, PatchMap | undefined>)[this._kOtListeners];\n }\n}\n"],"names":["AsyncLocalStorage","setIsSetup","ROOT_CONTEXT","buildContextWithSentryScopes","EventEmitter","SENTRY_SCOPES_CONTEXT_KEY"],"mappings":";;;;;;;;;;;;AAuCA,MAAM,uBAAuB,CAAC,aAAA,EAAe,IAAA,EAAM,MAAA,EAAQ,mBAAmB,qBAAqB,CAAA;AAM5F,MAAM,qCAAA,CAAgE;AAAA,EAMpE,WAAA,GAAc;AALrB,IAAA,IAAA,CAAmB,kBAAA,GAAqB,IAAIA,kCAAA,EAA2B;AAEvE,IAAA,IAAA,CAAiB,aAAA,0BAAuB,aAAa,CAAA;AACrD,IAAA,IAAA,CAAQ,QAAA,GAAW,KAAA;AAGjB,IAAAC,mBAAA,CAAW,sBAAsB,CAAA;AAAA,EACnC;AAAA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C;AAC3D,IAAA,OAAQ,EAAA,CAAuD,KAAK,aAAa,CAAA;AAAA,EACnF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/asyncLocalStorageContextManager.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * This implementation follows the behavior of OpenTelemetry’s `@opentelemetry/context-async-hooks`\n * package, combining logic that upstream splits across:\n * - https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts\n * - https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts\n * It is a single-class re-implementation for Sentry (not a verbatim copy of those files).\n */\n\nimport type { Context, ContextManager } from '@opentelemetry/api';\nimport { ROOT_CONTEXT } from '@opentelemetry/api';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { EventEmitter } from 'node:events';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from './constants';\nimport type { AsyncLocalStorageLookup } from './contextManager';\nimport { buildContextWithSentryScopes } from './utils/buildContextWithSentryScopes';\nimport { setIsSetup } from './utils/setupCheck';\n\ntype ListenerFn = (...args: unknown[]) => unknown;\n\n/**\n * Per-event map from user listeners to context-bound listeners.\n */\ntype PatchMap = Record<string, WeakMap<ListenerFn, ListenerFn>>;\n\nconst ADD_LISTENER_METHODS = ['addListener', 'on', 'once', 'prependListener', 'prependOnceListener'] as const;\n\n/**\n * OpenTelemetry-compatible context manager using Node.js `AsyncLocalStorage`.\n * Semantics match `@opentelemetry/context-async-hooks` (function `bind` + `EventEmitter` patching).\n */\nexport class SentryAsyncLocalStorageContextManager implements ContextManager {\n protected readonly _asyncLocalStorage = new AsyncLocalStorage<Context>();\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n\n public constructor() {\n setIsSetup('SentryContextManager');\n }\n\n public active(): Context {\n return this._asyncLocalStorage.getStore() ?? ROOT_CONTEXT;\n }\n\n public with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n const ctx2 = buildContextWithSentryScopes(context, this.active());\n const cb = thisArg == null ? fn : fn.bind(thisArg);\n return this._asyncLocalStorage.run(ctx2, cb as never, ...args);\n }\n\n public enable(): this {\n return this;\n }\n\n public disable(): this {\n this._asyncLocalStorage.disable();\n return this;\n }\n\n public bind<T>(context: Context, target: T): T {\n if (target instanceof EventEmitter) {\n return this._bindEventEmitter(context, target);\n }\n if (typeof target === 'function') {\n return this._bindFunction(context, target as unknown as ListenerFn) as T;\n }\n return target;\n }\n\n /**\n * Gets underlying AsyncLocalStorage and symbol to allow lookup of scope.\n * This is Sentry-specific.\n */\n public getAsyncLocalStorageLookup(): AsyncLocalStorageLookup {\n return {\n asyncLocalStorage: this._asyncLocalStorage,\n contextSymbol: SENTRY_SCOPES_CONTEXT_KEY,\n };\n }\n\n private _bindFunction(context: Context, target: ListenerFn): ListenerFn {\n const managerWith = this.with.bind(this);\n const contextWrapper = function (this: never, ...args: unknown[]) {\n return managerWith(context, () => target.apply(this, args));\n };\n Object.defineProperty(contextWrapper, 'length', {\n enumerable: false,\n configurable: true,\n writable: false,\n value: target.length,\n });\n return contextWrapper;\n }\n\n private _bindEventEmitter<T extends EventEmitter>(context: Context, ee: T): T {\n if (this._getPatchMap(ee) !== undefined) {\n return ee;\n }\n this._createPatchMap(ee);\n\n for (const methodName of ADD_LISTENER_METHODS) {\n if (ee[methodName] === undefined) continue;\n ee[methodName] = this._patchAddListener(\n ee,\n ee[methodName] as unknown as (...args: unknown[]) => unknown,\n context,\n );\n }\n if (typeof ee.removeListener === 'function') {\n // oxlint-disable-next-line @typescript-eslint/unbound-method -- patched like upstream OTel context manager\n ee.removeListener = this._patchRemoveListener(ee, ee.removeListener as (...args: unknown[]) => unknown);\n }\n if (typeof ee.off === 'function') {\n // oxlint-disable-next-line @typescript-eslint/unbound-method\n ee.off = this._patchRemoveListener(ee, ee.off as (...args: unknown[]) => unknown);\n }\n if (typeof ee.removeAllListeners === 'function') {\n ee.removeAllListeners = this._patchRemoveAllListeners(\n ee,\n // oxlint-disable-next-line @typescript-eslint/unbound-method\n ee.removeAllListeners as (...args: unknown[]) => unknown,\n );\n }\n return ee;\n }\n\n private _patchRemoveListener(ee: EventEmitter, original: (...args: unknown[]) => unknown) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event: string, listener: ListenerFn) {\n const events = contextManager._getPatchMap(ee)?.[event];\n if (events === undefined) {\n return original.call(this, event, listener);\n }\n const patchedListener = events.get(listener);\n return original.call(this, event, patchedListener || listener);\n };\n }\n\n private _patchRemoveAllListeners(ee: EventEmitter, original: (...args: unknown[]) => unknown) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event?: string) {\n const map = contextManager._getPatchMap(ee);\n if (map !== undefined) {\n if (arguments.length === 0) {\n contextManager._createPatchMap(ee);\n } else if (event !== undefined && map[event] !== undefined) {\n // oxlint-disable-next-line @typescript-eslint/no-dynamic-delete -- event-keyed listener map\n delete map[event];\n }\n }\n return original.apply(this, arguments);\n };\n }\n\n private _patchAddListener(ee: EventEmitter, original: (...args: unknown[]) => unknown, context: Context) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event: string, listener: ListenerFn) {\n if (contextManager._wrapped) {\n return original.call(this, event, listener);\n }\n let map = contextManager._getPatchMap(ee);\n if (map === undefined) {\n map = contextManager._createPatchMap(ee);\n }\n let listeners = map[event];\n if (listeners === undefined) {\n listeners = new WeakMap();\n map[event] = listeners;\n }\n const patchedListener = contextManager.bind(context, listener);\n listeners.set(listener, patchedListener);\n\n contextManager._wrapped = true;\n try {\n return original.call(this, event, patchedListener);\n } finally {\n contextManager._wrapped = false;\n }\n };\n }\n\n private _createPatchMap(ee: EventEmitter): PatchMap {\n const map = Object.create(null) as PatchMap;\n (ee as unknown as Record<symbol, PatchMap>)[this._kOtListeners] = map;\n return map;\n }\n\n private _getPatchMap(ee: EventEmitter): PatchMap | undefined {\n return (ee as unknown as Record<symbol, PatchMap | undefined>)[this._kOtListeners];\n }\n}\n"],"names":["AsyncLocalStorage","setIsSetup","ROOT_CONTEXT","buildContextWithSentryScopes","EventEmitter","SENTRY_SCOPES_CONTEXT_KEY"],"mappings":";;;;;;;;;;;AAuCA,MAAM,uBAAuB,CAAC,aAAA,EAAe,IAAA,EAAM,MAAA,EAAQ,mBAAmB,qBAAqB,CAAA;AAM5F,MAAM,qCAAA,CAAgE;AAAA,EAMpE,WAAA,GAAc;AALrB,IAAA,IAAA,CAAmB,kBAAA,GAAqB,IAAIA,kCAAA,EAA2B;AAEvE,IAAA,IAAA,CAAiB,aAAA,0BAAuB,aAAa,CAAA;AACrD,IAAA,IAAA,CAAQ,QAAA,GAAW,KAAA;AAGjB,IAAAC,mBAAA,CAAW,sBAAsB,CAAA;AAAA,EACnC;AAAA,EAEO,MAAA,GAAkB;AACvB,IAAA,OAAO,IAAA,CAAK,kBAAA,CAAmB,QAAA,EAAS,IAAKC,gBAAA;AAAA,EAC/C;AAAA,EAEO,IAAA,CACL,OAAA,EACA,EAAA,EACA,OAAA,EAAA,GACG,IAAA,EACY;AACf,IAAA,MAAM,IAAA,GAAOC,qCAAA,CAA6B,OAAA,EAAS,IAAA,CAAK,QAAQ,CAAA;AAChE,IAAA,MAAM,KAA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AAI,GAAA,GAAM,cAAA,CAAe,YAAA,CAAa,EAAE,CAAA;AACxC,MAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,QAAA,GAAA,GAAM,cAAA,CAAe,gBAAgB,EAAE,CAAA;AAAA,MACzC;AACA,MAAA,IAAI,SAAA,GAAY,IAAI,KAAK,CAAA;AACzB,MAAA,IAAI,cAAc,MAAA,EAAW;AAC3B,QAAA,SAAA,uBAAgB,OAAA,EAAQ;AACxB,QAAA,GAAA,CAAI,KAAK,CAAA,GAAI,SAAA;AAAA,MACf;AACA,MAAA,MAAM,eAAA,GAAkB,cAAA,CAAe,IAAA,CAAK,OAAA,EAAS,QAAQ,CAAA;AAC7D,MAAA,SAAA,CAAU,GAAA,CAAI,UAAU,eAAe,CAAA;AAEvC,MAAA,cAAA,CAAe,QAAA,GAAW,IAAA;AAC1B,MAAA,IAAI;AACF,QAAA,OAAO,QAAA,CAAS,IAAA,CAAK,IAAA,EAAM,KAAA,EAAO,eAAe,CAAA;AAAA,MACnD,CAAA,SAAE;AACA,QAAA,cAAA,CAAe,QAAA,GAAW,KAAA;AAAA,MAC5B;AAAA,IACF,CAAA;AAAA,EACF;AAAA,EAEQ,gBAAgB,EAAA,EAA4B;AAClD,IAAA,MAAM,GAAA,mBAAM,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA;AAC9B,IAAC,EAAA,CAA2C,IAAA,CAAK,aAAa,CAAA,GAAI,GAAA;AAClE,IAAA,OAAO,GAAA;AAAA,EACT;AAAA,EAEQ,aAAa,EAAA,EAAwC;AAC3D,IAAA,OAAQ,EAAA,CAAuD,KAAK,aAAa,CAAA;AAAA,EACnF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,6 @@ const api = require('@opentelemetry/api');
|
|
|
2
2
|
const core = require('@sentry/core');
|
|
3
3
|
const attributes = require('@sentry/conventions/attributes');
|
|
4
4
|
const core$1 = require('@opentelemetry/core');
|
|
5
|
-
const debugBuild = require('./debug-build-CQngOfDt.js');
|
|
6
5
|
const sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
|
7
6
|
|
|
8
7
|
const SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE = "sentry.parentIsRemote";
|
|
@@ -335,6 +334,8 @@ function getActiveSpan() {
|
|
|
335
334
|
return api.trace.getActiveSpan();
|
|
336
335
|
}
|
|
337
336
|
|
|
337
|
+
const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
|
|
338
|
+
|
|
338
339
|
class TraceState {
|
|
339
340
|
constructor() {
|
|
340
341
|
this._internalState = /* @__PURE__ */ new Map();
|
|
@@ -398,14 +399,14 @@ class SentryPropagator extends core$1.W3CBaggagePropagator {
|
|
|
398
399
|
*/
|
|
399
400
|
inject(context2, carrier, setter) {
|
|
400
401
|
if (core$1.isTracingSuppressed(context2)) {
|
|
401
|
-
|
|
402
|
+
DEBUG_BUILD && core.debug.log("[Tracing] Not injecting trace data for url because tracing is suppressed.");
|
|
402
403
|
return;
|
|
403
404
|
}
|
|
404
405
|
const activeSpan = api.trace.getSpan(context2);
|
|
405
406
|
const url = activeSpan && getCurrentURL(activeSpan);
|
|
406
407
|
const { tracePropagationTargets, propagateTraceparent } = core.getClient()?.getOptions() || {};
|
|
407
408
|
if (!core.shouldPropagateTraceForUrl(url, tracePropagationTargets, this._urlMatchesTargetsMap)) {
|
|
408
|
-
|
|
409
|
+
DEBUG_BUILD && core.debug.log("[Tracing] Not injecting trace data for url because it does not match tracePropagationTargets:", url);
|
|
409
410
|
return;
|
|
410
411
|
}
|
|
411
412
|
const existingBaggageHeader = getExistingBaggage(carrier);
|
|
@@ -845,7 +846,19 @@ function setOpenTelemetryContextAsyncContextStrategy() {
|
|
|
845
846
|
startNewTrace,
|
|
846
847
|
// The types here don't fully align, because our own `Span` type is narrower
|
|
847
848
|
// than the OTEL one - but this is OK for here, as we now we'll only have OTEL spans passed around
|
|
848
|
-
withActiveSpan
|
|
849
|
+
withActiveSpan,
|
|
850
|
+
getTracingChannelBinding: () => {
|
|
851
|
+
try {
|
|
852
|
+
const contextManager = api.context._getContextManager();
|
|
853
|
+
const lookup = contextManager.getAsyncLocalStorageLookup();
|
|
854
|
+
return {
|
|
855
|
+
asyncLocalStorage: lookup.asyncLocalStorage,
|
|
856
|
+
getStoreWithActiveSpan: (span) => api.trace.setSpan(api.context.active(), span)
|
|
857
|
+
};
|
|
858
|
+
} catch {
|
|
859
|
+
return void 0;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
849
862
|
});
|
|
850
863
|
}
|
|
851
864
|
|
|
@@ -1038,7 +1051,7 @@ class SentrySpanExporter {
|
|
|
1038
1051
|
}
|
|
1039
1052
|
});
|
|
1040
1053
|
if (droppedSpanCount > 0) {
|
|
1041
|
-
|
|
1054
|
+
DEBUG_BUILD && core.debug.log(
|
|
1042
1055
|
`SpanExporter dropped ${droppedSpanCount} spans because they were pending for more than ${this._finishedSpanBucketSize} seconds.`
|
|
1043
1056
|
);
|
|
1044
1057
|
}
|
|
@@ -1067,7 +1080,7 @@ class SentrySpanExporter {
|
|
|
1067
1080
|
const sentSpans = this._maybeSend(finishedSpans);
|
|
1068
1081
|
const sentSpanCount = sentSpans.size;
|
|
1069
1082
|
const remainingOpenSpanCount = finishedSpans.length - sentSpanCount;
|
|
1070
|
-
|
|
1083
|
+
DEBUG_BUILD && core.debug.log(
|
|
1071
1084
|
`SpanExporter exported ${sentSpanCount} spans, ${remainingOpenSpanCount} spans are waiting for their parent spans to finish`
|
|
1072
1085
|
);
|
|
1073
1086
|
for (const span of sentSpans) {
|
|
@@ -1364,7 +1377,7 @@ function backfillStreamedSpanDataFromOtel(spanJSON, hint) {
|
|
|
1364
1377
|
if (!attributes) {
|
|
1365
1378
|
return;
|
|
1366
1379
|
}
|
|
1367
|
-
const kind = hint?.spanKind ??
|
|
1380
|
+
const kind = hint?.spanKind ?? core.SPAN_KIND.INTERNAL;
|
|
1368
1381
|
const { op, description, source, data } = inferSpanData(spanJSON.name, attributes, kind);
|
|
1369
1382
|
spanJSON.name = description;
|
|
1370
1383
|
core.safeSetSpanJSONAttributes(spanJSON, {
|
|
@@ -1372,9 +1385,9 @@ function backfillStreamedSpanDataFromOtel(spanJSON, hint) {
|
|
|
1372
1385
|
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
|
|
1373
1386
|
...data
|
|
1374
1387
|
});
|
|
1375
|
-
if (kind !==
|
|
1388
|
+
if (kind !== core.SPAN_KIND.INTERNAL) {
|
|
1376
1389
|
core.safeSetSpanJSONAttributes(spanJSON, {
|
|
1377
|
-
"otel.kind":
|
|
1390
|
+
"otel.kind": core.spanKindToName(kind)
|
|
1378
1391
|
});
|
|
1379
1392
|
}
|
|
1380
1393
|
}
|
|
@@ -1496,7 +1509,7 @@ class SentrySampler {
|
|
|
1496
1509
|
);
|
|
1497
1510
|
const method = `${maybeSpanHttpMethod}`.toUpperCase();
|
|
1498
1511
|
if (method === "OPTIONS" || method === "HEAD") {
|
|
1499
|
-
|
|
1512
|
+
DEBUG_BUILD && core.debug.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
|
|
1500
1513
|
return wrapSamplingDecision({
|
|
1501
1514
|
decision: sdkTraceBase.SamplingDecision.NOT_RECORD,
|
|
1502
1515
|
context,
|
|
@@ -1508,7 +1521,7 @@ class SentrySampler {
|
|
|
1508
1521
|
}
|
|
1509
1522
|
if (!sampled && // We check for `parentSampled === undefined` because we only want to record client reports for spans that are trace roots (ie. when there was incoming trace)
|
|
1510
1523
|
parentSampled === void 0) {
|
|
1511
|
-
|
|
1524
|
+
DEBUG_BUILD && core.debug.log("[Tracing] Discarding root span because its trace was not chosen to be sampled.");
|
|
1512
1525
|
this._client.recordDroppedEvent("sample_rate", this._isSpanStreaming ? "span" : "transaction");
|
|
1513
1526
|
}
|
|
1514
1527
|
return {
|
|
@@ -1535,11 +1548,11 @@ function getParentSampled(parentSpan, traceId, spanName) {
|
|
|
1535
1548
|
if (api.isSpanContextValid(parentContext) && parentContext.traceId === traceId) {
|
|
1536
1549
|
if (parentContext.isRemote) {
|
|
1537
1550
|
const parentSampled2 = getSamplingDecision(parentSpan.spanContext());
|
|
1538
|
-
|
|
1551
|
+
DEBUG_BUILD && core.debug.log(`[Tracing] Inheriting remote parent's sampled decision for ${spanName}: ${parentSampled2}`);
|
|
1539
1552
|
return parentSampled2;
|
|
1540
1553
|
}
|
|
1541
1554
|
const parentSampled = getSamplingDecision(parentContext);
|
|
1542
|
-
|
|
1555
|
+
DEBUG_BUILD && core.debug.log(`[Tracing] Inheriting parent's sampled decision for ${spanName}: ${parentSampled}`);
|
|
1543
1556
|
return parentSampled;
|
|
1544
1557
|
}
|
|
1545
1558
|
return void 0;
|
|
@@ -1686,4 +1699,4 @@ exports.withActiveSpan = withActiveSpan;
|
|
|
1686
1699
|
exports.wrapClientClass = wrapClientClass;
|
|
1687
1700
|
exports.wrapContextManagerClass = wrapContextManagerClass;
|
|
1688
1701
|
exports.wrapSamplingDecision = wrapSamplingDecision;
|
|
1689
|
-
//# sourceMappingURL=resource-
|
|
1702
|
+
//# sourceMappingURL=resource-DuZKnQnC.js.map
|