@sentry/opentelemetry
Advanced tools
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const core = require('@sentry/core'); | ||
| const asyncContextStrategy = require('./asyncContextStrategy-DP1H8zYV.js'); | ||
| const asyncContextStrategy = require('./asyncContextStrategy-volGaYqZ.js'); | ||
@@ -6,0 +6,0 @@ class SentryAsyncLocalStorageContextManager { |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const asyncContextStrategy = require('./asyncContextStrategy-DP1H8zYV.js'); | ||
| const asyncContextStrategy = require('./asyncContextStrategy-volGaYqZ.js'); | ||
| const core = require('@sentry/core'); | ||
@@ -162,3 +162,3 @@ const api = require('@opentelemetry/api'); | ||
| asyncLocalStorage: defaultAsyncLocalStorage, | ||
| getStoreWithActiveSpan: (span) => api.trace.setSpan(api.context.active(), span) | ||
| getStoreWithActiveSpan | ||
| }; | ||
@@ -174,3 +174,3 @@ }; | ||
| asyncLocalStorage, | ||
| getStoreWithActiveSpan: (span) => api.trace.setSpan(api.context.active(), span) | ||
| getStoreWithActiveSpan | ||
| } : void 0; | ||
@@ -182,2 +182,7 @@ } catch { | ||
| } | ||
| function getStoreWithActiveSpan(span) { | ||
| const activeContext = api.context.active(); | ||
| const isIgnoredChild = core.spanIsIgnored(span) && core.getRootSpan(span) !== span || span.spanContext().traceState?.get(asyncContextStrategy.SENTRY_TRACE_STATE_CHILD_IGNORED) === "1"; | ||
| return isIgnoredChild ? activeContext : api.trace.setSpan(activeContext, span); | ||
| } | ||
@@ -184,0 +189,0 @@ exports.SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION = asyncContextStrategy.SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../src/asyncLocalStorageContextManager.ts","../../src/nodeAsyncContextStrategy.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 type { AsyncLocalStorageLookup } from './contextManager';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from './constants';\nimport { buildContextWithSentryScopes } from './utils/buildContextWithSentryScopes';\nimport { setIsSetup } from './utils/setupCheck';\nimport { getAsyncContextStrategy, getMainCarrier } from '@sentry/core';\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: AsyncLocalStorage<Context>;\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n\n public constructor() {\n setIsSetup('SentryContextManager');\n // Pick the instance from the async context strategy\n // this should normally always be there, but if it is not for whatever reason, we fall back to a new instance\n this._asyncLocalStorage =\n (getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.()\n ?.asyncLocalStorage as AsyncLocalStorage<Context>) ?? new AsyncLocalStorage<Context>();\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","import * as api from '@opentelemetry/api';\nimport { setOpenTelemetryContextAsyncContextStrategy } from './asyncContextStrategy';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport type { TracingChannelBinding } from '@sentry/core';\n\ninterface ContextApi {\n _getContextManager():\n | undefined\n | {\n getAsyncLocalStorageLookup(): {\n asyncLocalStorage: unknown;\n };\n };\n}\n\nexport function setNodeOpenTelemetryContextAsyncContextStrategy(options?: { skipOpenTelemetrySetup?: boolean }): void {\n setOpenTelemetryContextAsyncContextStrategy({\n getTracingChannelBinding: !options?.skipOpenTelemetrySetup\n ? getDefaultAsyncLocalStorageFactory()\n : getCustomAsyncLocalStorageFactory(),\n });\n}\n\n/**\n * In the default case, we build the local storage instance ourselves here.\n * The default asyncLocalStorageContextManager will then use this internally.\n */\nfunction getDefaultAsyncLocalStorageFactory(): () => TracingChannelBinding {\n const defaultAsyncLocalStorage = new AsyncLocalStorage<api.Context>();\n\n return () => {\n return {\n asyncLocalStorage: defaultAsyncLocalStorage,\n getStoreWithActiveSpan: span => api.trace.setSpan(api.context.active(), span),\n } satisfies TracingChannelBinding;\n };\n}\n\n/**\n * If we have a custom context manager, we need to access it via the context manager\n * this may not be available yet, if this is called before the Otel ContextManager was setup\n * in this case, we need to return undefined and retry later, hoping that the setup works by then\n */\nfunction getCustomAsyncLocalStorageFactory(): () => TracingChannelBinding | undefined {\n return () => {\n try {\n const contextManager = (api.context as unknown as ContextApi)._getContextManager();\n const asyncLocalStorage = contextManager?.getAsyncLocalStorageLookup().asyncLocalStorage;\n\n return asyncLocalStorage\n ? ({\n asyncLocalStorage,\n getStoreWithActiveSpan: span => api.trace.setSpan(api.context.active(), span as api.Span),\n } satisfies TracingChannelBinding)\n : undefined;\n } catch {\n return undefined;\n }\n };\n}\n"],"names":["setIsSetup","getAsyncContextStrategy","getMainCarrier","AsyncLocalStorage","ROOT_CONTEXT","buildContextWithSentryScopes","EventEmitter","SENTRY_SCOPES_CONTEXT_KEY","setOpenTelemetryContextAsyncContextStrategy"],"mappings":";;;;;;;;AAwCA,MAAM,uBAAuB,CAAC,aAAA,EAAe,IAAA,EAAM,MAAA,EAAQ,mBAAmB,qBAAqB,CAAA;AAM5F,MAAM,qCAAA,CAAgE;AAAA,EAMpE,WAAA,GAAc;AAHrB,IAAA,IAAA,CAAiB,aAAA,0BAAuB,aAAa,CAAA;AACrD,IAAA,IAAA,CAAQ,QAAA,GAAW,KAAA;AAGjB,IAAAA,+BAAA,CAAW,sBAAsB,CAAA;AAGjC,IAAA,IAAA,CAAK,kBAAA,GACFC,6BAAwBC,mBAAA,EAAgB,EAAE,wBAAA,IAA2B,EAClE,iBAAA,IAAoD,IAAIC,kCAAA,EAA2B;AAAA,EAC3F;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,iDAAA,CAA6B,OAAA,EAAS,IAAA,CAAK,QAAQ,CAAA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AACzE,EAAA,MAAM,wBAAA,GAA2B,IAAIL,kCAAA,EAA+B;AAEpE,EAAA,OAAO,MAAM;AACX,IAAA,OAAO;AAAA,MACL,iBAAA,EAAmB,wBAAA;AAAA,MACnB,sBAAA,EAAwB,UAAQ,GAAA,CAAI,KAAA,CAAM,QAAQ,GAAA,CAAI,OAAA,CAAQ,MAAA,EAAO,EAAG,IAAI;AAAA,KAC9E;AAAA,EACF,CAAA;AACF;AAOA,SAAS,iCAAA,GAA6E;AACpF,EAAA,OAAO,MAAM;AACX,IAAA,IAAI;AACF,MAAA,MAAM,cAAA,GAAkB,GAAA,CAAI,OAAA,CAAkC,kBAAA,EAAmB;AACjF,MAAA,MAAM,iBAAA,GAAoB,cAAA,EAAgB,0BAAA,EAA2B,CAAE,iBAAA;AAEvE,MAAA,OAAO,iBAAA,GACF;AAAA,QACC,iBAAA;AAAA,QACA,sBAAA,EAAwB,UAAQ,GAAA,CAAI,KAAA,CAAM,QAAQ,GAAA,CAAI,OAAA,CAAQ,MAAA,EAAO,EAAG,IAAgB;AAAA,OAC1F,GACA,KAAA,CAAA;AAAA,IACN,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF,CAAA;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../src/asyncLocalStorageContextManager.ts","../../src/nodeAsyncContextStrategy.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 type { AsyncLocalStorageLookup } from './contextManager';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from './constants';\nimport { buildContextWithSentryScopes } from './utils/buildContextWithSentryScopes';\nimport { setIsSetup } from './utils/setupCheck';\nimport { getAsyncContextStrategy, getMainCarrier } from '@sentry/core';\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: AsyncLocalStorage<Context>;\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n\n public constructor() {\n setIsSetup('SentryContextManager');\n // Pick the instance from the async context strategy\n // this should normally always be there, but if it is not for whatever reason, we fall back to a new instance\n this._asyncLocalStorage =\n (getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.()\n ?.asyncLocalStorage as AsyncLocalStorage<Context>) ?? new AsyncLocalStorage<Context>();\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","import * as api from '@opentelemetry/api';\nimport { setOpenTelemetryContextAsyncContextStrategy } from './asyncContextStrategy';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { getRootSpan, spanIsIgnored, type TracingChannelBinding } from '@sentry/core';\nimport { SENTRY_TRACE_STATE_CHILD_IGNORED } from './constants';\n\ninterface ContextApi {\n _getContextManager():\n | undefined\n | {\n getAsyncLocalStorageLookup(): {\n asyncLocalStorage: unknown;\n };\n };\n}\n\nexport function setNodeOpenTelemetryContextAsyncContextStrategy(options?: { skipOpenTelemetrySetup?: boolean }): void {\n setOpenTelemetryContextAsyncContextStrategy({\n getTracingChannelBinding: !options?.skipOpenTelemetrySetup\n ? getDefaultAsyncLocalStorageFactory()\n : getCustomAsyncLocalStorageFactory(),\n });\n}\n\n/**\n * In the default case, we build the local storage instance ourselves here.\n * The default asyncLocalStorageContextManager will then use this internally.\n */\nfunction getDefaultAsyncLocalStorageFactory(): () => TracingChannelBinding {\n const defaultAsyncLocalStorage = new AsyncLocalStorage<api.Context>();\n\n return () => {\n return {\n asyncLocalStorage: defaultAsyncLocalStorage,\n getStoreWithActiveSpan,\n } satisfies TracingChannelBinding;\n };\n}\n\n/**\n * If we have a custom context manager, we need to access it via the context manager\n * this may not be available yet, if this is called before the Otel ContextManager was setup\n * in this case, we need to return undefined and retry later, hoping that the setup works by then\n */\nfunction getCustomAsyncLocalStorageFactory(): () => TracingChannelBinding | undefined {\n return () => {\n try {\n const contextManager = (api.context as unknown as ContextApi)._getContextManager();\n const asyncLocalStorage = contextManager?.getAsyncLocalStorageLookup().asyncLocalStorage;\n\n return asyncLocalStorage\n ? ({\n asyncLocalStorage,\n getStoreWithActiveSpan,\n } satisfies TracingChannelBinding)\n : undefined;\n } catch {\n return undefined;\n }\n };\n}\n\nfunction getStoreWithActiveSpan(span: Parameters<TracingChannelBinding['getStoreWithActiveSpan']>[0]): api.Context {\n const activeContext = api.context.active();\n\n // Tracing channels bind directly to the context manager's AsyncLocalStorage and bypass\n // SentryContextManager.with(), so ignored children must restore their parent here as well.\n const isIgnoredChild =\n (spanIsIgnored(span) && getRootSpan(span) !== span) ||\n span.spanContext().traceState?.get(SENTRY_TRACE_STATE_CHILD_IGNORED) === '1';\n\n return isIgnoredChild ? activeContext : api.trace.setSpan(activeContext, span);\n}\n"],"names":["setIsSetup","getAsyncContextStrategy","getMainCarrier","AsyncLocalStorage","ROOT_CONTEXT","buildContextWithSentryScopes","EventEmitter","SENTRY_SCOPES_CONTEXT_KEY","setOpenTelemetryContextAsyncContextStrategy","spanIsIgnored","getRootSpan","SENTRY_TRACE_STATE_CHILD_IGNORED"],"mappings":";;;;;;;;AAwCA,MAAM,uBAAuB,CAAC,aAAA,EAAe,IAAA,EAAM,MAAA,EAAQ,mBAAmB,qBAAqB,CAAA;AAM5F,MAAM,qCAAA,CAAgE;AAAA,EAMpE,WAAA,GAAc;AAHrB,IAAA,IAAA,CAAiB,aAAA,0BAAuB,aAAa,CAAA;AACrD,IAAA,IAAA,CAAQ,QAAA,GAAW,KAAA;AAGjB,IAAAA,+BAAA,CAAW,sBAAsB,CAAA;AAGjC,IAAA,IAAA,CAAK,kBAAA,GACFC,6BAAwBC,mBAAA,EAAgB,EAAE,wBAAA,IAA2B,EAClE,iBAAA,IAAoD,IAAIC,kCAAA,EAA2B;AAAA,EAC3F;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,iDAAA,CAA6B,OAAA,E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H;AAMA,SAAS,kCAAA,GAAkE;AACzE,EAAA,MAAM,wBAAA,GAA2B,IAAIL,kCAAA,EAA+B;AAEpE,EAAA,OAAO,MAAM;AACX,IAAA,OAAO;AAAA,MACL,iBAAA,EAAmB,wBAAA;AAAA,MACnB;AAAA,KACF;AAAA,EACF,CAAA;AACF;AAOA,SAAS,iCAAA,GAA6E;AACpF,EAAA,OAAO,MAAM;AACX,IAAA,IAAI;AACF,MAAA,MAAM,cAAA,GAAkB,GAAA,CAAI,OAAA,CAAkC,kBAAA,EAAmB;AACjF,MAAA,MAAM,iBAAA,GAAoB,cAAA,EAAgB,0BAAA,EAA2B,CAAE,iBAAA;AAEvE,MAAA,OAAO,iBAAA,GACF;AAAA,QACC,iBAAA;AAAA,QACA;AAAA,OACF,GACA,KAAA,CAAA;AAAA,IACN,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF,CAAA;AACF;AAEA,SAAS,uBAAuB,IAAA,EAAmF;AACjH,EAAA,MAAM,aAAA,GAAgB,GAAA,CAAI,OAAA,CAAQ,MAAA,EAAO;AAIzC,EAAA,MAAM,cAAA,GACHM,kBAAA,CAAc,IAAI,CAAA,IAAKC,iBAAY,IAAI,CAAA,KAAM,IAAA,IAC9C,IAAA,CAAK,WAAA,EAAY,CAAE,UAAA,EAAY,GAAA,CAAIC,qDAAgC,CAAA,KAAM,GAAA;AAE3E,EAAA,OAAO,iBAAiB,aAAA,GAAgB,GAAA,CAAI,KAAA,CAAM,OAAA,CAAQ,eAAe,IAAI,CAAA;AAC/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
| import { consoleSandbox } from '@sentry/core'; | ||
| export { getClient, getDynamicSamplingContextFromSpan, shouldPropagateTraceForUrl, withStreamedSpan } from '@sentry/core'; | ||
| export { S as SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, b as SentryPropagator, c as SentrySampler, d as SentrySpanProcessor, e as SentryTracerProvider, f as applyOtelSpanData, g as backfillStreamedSpanDataFromOtel, i as continueTrace, j as enhanceDscWithOpenTelemetryRootSpanName, k as getActiveSpan, l as getRequestSpanData, m as getScopesFromContext, n as getSentryResource, o as getSpanKind, p as getTraceContextForScope, q as isSentryRequestSpan, r as openTelemetrySetupCheck, s as setIsSetup, t as setOpenTelemetryContextAsyncContextStrategy, u as setupEventContextTrace, v as spanHasAttributes, w as spanHasEvents, x as spanHasKind, y as spanHasName, z as spanHasParentId, A as spanHasStatus, B as startInactiveSpan, C as startSpan, D as startSpanManual, E as suppressTracing, F as withActiveSpan, G as wrapClientClass, H as wrapContextManagerClass, I as wrapSamplingDecision } from './asyncContextStrategy-CDufUmpa.js'; | ||
| export { S as SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, c as SentryPropagator, d as SentrySampler, e as SentrySpanProcessor, f as SentryTracerProvider, g as applyOtelSpanData, h as backfillStreamedSpanDataFromOtel, j as continueTrace, k as enhanceDscWithOpenTelemetryRootSpanName, l as getActiveSpan, m as getRequestSpanData, n as getScopesFromContext, o as getSentryResource, p as getSpanKind, q as getTraceContextForScope, r as isSentryRequestSpan, s as openTelemetrySetupCheck, t as setIsSetup, u as setOpenTelemetryContextAsyncContextStrategy, v as setupEventContextTrace, w as spanHasAttributes, x as spanHasEvents, y as spanHasKind, z as spanHasName, A as spanHasParentId, B as spanHasStatus, C as startInactiveSpan, D as startSpan, E as startSpanManual, F as suppressTracing, G as withActiveSpan, H as wrapClientClass, I as wrapContextManagerClass, J as wrapSamplingDecision } from './asyncContextStrategy-CL7X6mXf.js'; | ||
@@ -5,0 +5,0 @@ class SentryAsyncLocalStorageContextManager { |
+10
-5
@@ -1,4 +0,4 @@ | ||
| import { s as setIsSetup, h as buildContextWithSentryScopes, a as SENTRY_SCOPES_CONTEXT_KEY, t as setOpenTelemetryContextAsyncContextStrategy } from './asyncContextStrategy-CDufUmpa.js'; | ||
| export { S as SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, b as SentryPropagator, c as SentrySampler, d as SentrySpanProcessor, e as SentryTracerProvider, f as applyOtelSpanData, g as backfillStreamedSpanDataFromOtel, i as continueTrace, j as enhanceDscWithOpenTelemetryRootSpanName, k as getActiveSpan, l as getRequestSpanData, m as getScopesFromContext, n as getSentryResource, o as getSpanKind, p as getTraceContextForScope, q as isSentryRequestSpan, r as openTelemetrySetupCheck, u as setupEventContextTrace, v as spanHasAttributes, w as spanHasEvents, x as spanHasKind, y as spanHasName, z as spanHasParentId, A as spanHasStatus, B as startInactiveSpan, C as startSpan, D as startSpanManual, E as suppressTracing, F as withActiveSpan, G as wrapClientClass, H as wrapContextManagerClass, I as wrapSamplingDecision } from './asyncContextStrategy-CDufUmpa.js'; | ||
| import { getAsyncContextStrategy, getMainCarrier } from '@sentry/core'; | ||
| import { t as setIsSetup, i as buildContextWithSentryScopes, a as SENTRY_SCOPES_CONTEXT_KEY, u as setOpenTelemetryContextAsyncContextStrategy, b as SENTRY_TRACE_STATE_CHILD_IGNORED } from './asyncContextStrategy-CL7X6mXf.js'; | ||
| export { S as SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, c as SentryPropagator, d as SentrySampler, e as SentrySpanProcessor, f as SentryTracerProvider, g as applyOtelSpanData, h as backfillStreamedSpanDataFromOtel, j as continueTrace, k as enhanceDscWithOpenTelemetryRootSpanName, l as getActiveSpan, m as getRequestSpanData, n as getScopesFromContext, o as getSentryResource, p as getSpanKind, q as getTraceContextForScope, r as isSentryRequestSpan, s as openTelemetrySetupCheck, v as setupEventContextTrace, w as spanHasAttributes, x as spanHasEvents, y as spanHasKind, z as spanHasName, A as spanHasParentId, B as spanHasStatus, C as startInactiveSpan, D as startSpan, E as startSpanManual, F as suppressTracing, G as withActiveSpan, H as wrapClientClass, I as wrapContextManagerClass, J as wrapSamplingDecision } from './asyncContextStrategy-CL7X6mXf.js'; | ||
| import { getAsyncContextStrategy, getMainCarrier, spanIsIgnored, getRootSpan } from '@sentry/core'; | ||
| export { getClient, getDynamicSamplingContextFromSpan, shouldPropagateTraceForUrl, withStreamedSpan } from '@sentry/core'; | ||
@@ -163,3 +163,3 @@ import * as api from '@opentelemetry/api'; | ||
| asyncLocalStorage: defaultAsyncLocalStorage, | ||
| getStoreWithActiveSpan: (span) => api.trace.setSpan(api.context.active(), span) | ||
| getStoreWithActiveSpan | ||
| }; | ||
@@ -175,3 +175,3 @@ }; | ||
| asyncLocalStorage, | ||
| getStoreWithActiveSpan: (span) => api.trace.setSpan(api.context.active(), span) | ||
| getStoreWithActiveSpan | ||
| } : void 0; | ||
@@ -183,4 +183,9 @@ } catch { | ||
| } | ||
| function getStoreWithActiveSpan(span) { | ||
| const activeContext = api.context.active(); | ||
| const isIgnoredChild = spanIsIgnored(span) && getRootSpan(span) !== span || span.spanContext().traceState?.get(SENTRY_TRACE_STATE_CHILD_IGNORED) === "1"; | ||
| return isIgnoredChild ? activeContext : api.trace.setSpan(activeContext, span); | ||
| } | ||
| export { SentryAsyncLocalStorageContextManager, setIsSetup, setNodeOpenTelemetryContextAsyncContextStrategy as setOpenTelemetryContextAsyncContextStrategy }; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../src/asyncLocalStorageContextManager.ts","../../src/nodeAsyncContextStrategy.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 type { AsyncLocalStorageLookup } from './contextManager';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from './constants';\nimport { buildContextWithSentryScopes } from './utils/buildContextWithSentryScopes';\nimport { setIsSetup } from './utils/setupCheck';\nimport { getAsyncContextStrategy, getMainCarrier } from '@sentry/core';\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: AsyncLocalStorage<Context>;\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n\n public constructor() {\n setIsSetup('SentryContextManager');\n // Pick the instance from the async context strategy\n // this should normally always be there, but if it is not for whatever reason, we fall back to a new instance\n this._asyncLocalStorage =\n (getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.()\n ?.asyncLocalStorage as AsyncLocalStorage<Context>) ?? new AsyncLocalStorage<Context>();\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","import * as api from '@opentelemetry/api';\nimport { setOpenTelemetryContextAsyncContextStrategy } from './asyncContextStrategy';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport type { TracingChannelBinding } from '@sentry/core';\n\ninterface ContextApi {\n _getContextManager():\n | undefined\n | {\n getAsyncLocalStorageLookup(): {\n asyncLocalStorage: unknown;\n };\n };\n}\n\nexport function setNodeOpenTelemetryContextAsyncContextStrategy(options?: { skipOpenTelemetrySetup?: boolean }): void {\n setOpenTelemetryContextAsyncContextStrategy({\n getTracingChannelBinding: !options?.skipOpenTelemetrySetup\n ? getDefaultAsyncLocalStorageFactory()\n : getCustomAsyncLocalStorageFactory(),\n });\n}\n\n/**\n * In the default case, we build the local storage instance ourselves here.\n * The default asyncLocalStorageContextManager will then use this internally.\n */\nfunction getDefaultAsyncLocalStorageFactory(): () => TracingChannelBinding {\n const defaultAsyncLocalStorage = new AsyncLocalStorage<api.Context>();\n\n return () => {\n return {\n asyncLocalStorage: defaultAsyncLocalStorage,\n getStoreWithActiveSpan: span => api.trace.setSpan(api.context.active(), span),\n } satisfies TracingChannelBinding;\n };\n}\n\n/**\n * If we have a custom context manager, we need to access it via the context manager\n * this may not be available yet, if this is called before the Otel ContextManager was setup\n * in this case, we need to return undefined and retry later, hoping that the setup works by then\n */\nfunction getCustomAsyncLocalStorageFactory(): () => TracingChannelBinding | undefined {\n return () => {\n try {\n const contextManager = (api.context as unknown as ContextApi)._getContextManager();\n const asyncLocalStorage = contextManager?.getAsyncLocalStorageLookup().asyncLocalStorage;\n\n return asyncLocalStorage\n ? ({\n asyncLocalStorage,\n getStoreWithActiveSpan: span => api.trace.setSpan(api.context.active(), span as api.Span),\n } satisfies TracingChannelBinding)\n : undefined;\n } catch {\n return undefined;\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;A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GAAA,CAAI,KAAA,CAAM,QAAQ,GAAA,CAAI,OAAA,CAAQ,MAAA,EAAO,EAAG,IAAgB;AAAA,OAC1F,GACA,KAAA,CAAA;AAAA,IACN,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF,CAAA;AACF;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../src/asyncLocalStorageContextManager.ts","../../src/nodeAsyncContextStrategy.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 type { AsyncLocalStorageLookup } from './contextManager';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from './constants';\nimport { buildContextWithSentryScopes } from './utils/buildContextWithSentryScopes';\nimport { setIsSetup } from './utils/setupCheck';\nimport { getAsyncContextStrategy, getMainCarrier } from '@sentry/core';\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: AsyncLocalStorage<Context>;\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n\n public constructor() {\n setIsSetup('SentryContextManager');\n // Pick the instance from the async context strategy\n // this should normally always be there, but if it is not for whatever reason, we fall back to a new instance\n this._asyncLocalStorage =\n (getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.()\n ?.asyncLocalStorage as AsyncLocalStorage<Context>) ?? new AsyncLocalStorage<Context>();\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","import * as api from '@opentelemetry/api';\nimport { setOpenTelemetryContextAsyncContextStrategy } from './asyncContextStrategy';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { getRootSpan, spanIsIgnored, type TracingChannelBinding } from '@sentry/core';\nimport { SENTRY_TRACE_STATE_CHILD_IGNORED } from './constants';\n\ninterface ContextApi {\n _getContextManager():\n | undefined\n | {\n getAsyncLocalStorageLookup(): {\n asyncLocalStorage: unknown;\n };\n };\n}\n\nexport function setNodeOpenTelemetryContextAsyncContextStrategy(options?: { skipOpenTelemetrySetup?: boolean }): void {\n setOpenTelemetryContextAsyncContextStrategy({\n getTracingChannelBinding: !options?.skipOpenTelemetrySetup\n ? getDefaultAsyncLocalStorageFactory()\n : getCustomAsyncLocalStorageFactory(),\n });\n}\n\n/**\n * In the default case, we build the local storage instance ourselves here.\n * The default asyncLocalStorageContextManager will then use this internally.\n */\nfunction getDefaultAsyncLocalStorageFactory(): () => TracingChannelBinding {\n const defaultAsyncLocalStorage = new AsyncLocalStorage<api.Context>();\n\n return () => {\n return {\n asyncLocalStorage: defaultAsyncLocalStorage,\n getStoreWithActiveSpan,\n } satisfies TracingChannelBinding;\n };\n}\n\n/**\n * If we have a custom context manager, we need to access it via the context manager\n * this may not be available yet, if this is called before the Otel ContextManager was setup\n * in this case, we need to return undefined and retry later, hoping that the setup works by then\n */\nfunction getCustomAsyncLocalStorageFactory(): () => TracingChannelBinding | undefined {\n return () => {\n try {\n const contextManager = (api.context as unknown as ContextApi)._getContextManager();\n const asyncLocalStorage = contextManager?.getAsyncLocalStorageLookup().asyncLocalStorage;\n\n return asyncLocalStorage\n ? ({\n asyncLocalStorage,\n getStoreWithActiveSpan,\n } satisfies TracingChannelBinding)\n : undefined;\n } catch {\n return undefined;\n }\n };\n}\n\nfunction getStoreWithActiveSpan(span: Parameters<TracingChannelBinding['getStoreWithActiveSpan']>[0]): api.Context {\n const activeContext = api.context.active();\n\n // Tracing channels bind directly to the context manager's AsyncLocalStorage and bypass\n // SentryContextManager.with(), so ignored children must restore their parent here as well.\n const isIgnoredChild =\n (spanIsIgnored(span) && getRootSpan(span) !== span) ||\n span.spanContext().traceState?.get(SENTRY_TRACE_STATE_CHILD_IGNORED) === '1';\n\n return isIgnoredChild ? activeContext : api.trace.setSpan(activeContext, span);\n}\n"],"names":[],"mappings":";;;;;;;;;AAwCA,MAAM,uBAAuB,CAAC,aAAA,EAAe,IAAA,EAAM,MAAA,EAAQ,mBAAmB,qBAAqB,CAAA;AAM5F,MAAM,qCAAA,CAAgE;AAAA,EAMpE,WAAA,GAAc;AAHrB,IAAA,IAAA,CAAiB,aAAA,0BAAuB,aAAa,CAAA;AACrD,IAAA,IAAA,CAAQ,QAA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,EAAY,GAAA,CAAI,gCAAgC,CAAA,KAAM,GAAA;AAE3E,EAAA,OAAO,iBAAiB,aAAA,GAAgB,GAAA,CAAI,KAAA,CAAM,OAAA,CAAQ,eAAe,IAAI,CAAA;AAC/E;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"type":"module","version":"10.65.0","sideEffects":false} | ||
| {"type":"module","version":"10.66.0","sideEffects":false} |
@@ -17,6 +17,6 @@ import { SpanContext } from '@opentelemetry/api'; | ||
| * span's own decision via `spanIsSampled` — but only for an *explicit* decision. An explicit decision | ||
| * always originates at a real `SentrySpan` root (a negatively sampled root, or a child of one). A | ||
| * non-recording placeholder root (an orphan/suppressed span, or a TwP placeholder) and a remote span | ||
| * have a *deferred* decision that lives elsewhere (the scope, or the incoming trace state), so we | ||
| * return `undefined` and leave the decision deferred rather than wrongly asserting `-0`. | ||
| * originates at a real `SentrySpan` root (a negatively sampled root, or a child of one) or an ignored | ||
| * segment root. Other non-recording placeholder roots (orphan/suppressed spans or TwP placeholders) | ||
| * and remote spans have a *deferred* decision that lives elsewhere (the scope, or the incoming trace | ||
| * state), so we return `undefined` rather than wrongly asserting `-0`. | ||
| * | ||
@@ -23,0 +23,0 @@ * TODO(v11): Once the OTel SDK provider is gone and every local span is a native Sentry span, the |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"nodeAsyncContextStrategy.d.ts","sourceRoot":"","sources":["../../src/nodeAsyncContextStrategy.ts"],"names":[],"mappings":"AAeA,wBAAgB,+CAA+C,CAAC,OAAO,CAAC,EAAE;IAAE,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAMpH"} | ||
| {"version":3,"file":"nodeAsyncContextStrategy.d.ts","sourceRoot":"","sources":["../../src/nodeAsyncContextStrategy.ts"],"names":[],"mappings":"AAgBA,wBAAgB,+CAA+C,CAAC,OAAO,CAAC,EAAE;IAAE,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAMpH"} |
@@ -17,6 +17,6 @@ import type { SpanContext } from '@opentelemetry/api'; | ||
| * span's own decision via `spanIsSampled` — but only for an *explicit* decision. An explicit decision | ||
| * always originates at a real `SentrySpan` root (a negatively sampled root, or a child of one). A | ||
| * non-recording placeholder root (an orphan/suppressed span, or a TwP placeholder) and a remote span | ||
| * have a *deferred* decision that lives elsewhere (the scope, or the incoming trace state), so we | ||
| * return `undefined` and leave the decision deferred rather than wrongly asserting `-0`. | ||
| * originates at a real `SentrySpan` root (a negatively sampled root, or a child of one) or an ignored | ||
| * segment root. Other non-recording placeholder roots (orphan/suppressed spans or TwP placeholders) | ||
| * and remote spans have a *deferred* decision that lives elsewhere (the scope, or the incoming trace | ||
| * state), so we return `undefined` rather than wrongly asserting `-0`. | ||
| * | ||
@@ -23,0 +23,0 @@ * TODO(v11): Once the OTel SDK provider is gone and every local span is a native Sentry span, the |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"getSamplingDecision.d.ts","sourceRoot":"","sources":["../../../src/utils/getSamplingDecision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAUjD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS,CA6BjF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAoBpG"} | ||
| {"version":3,"file":"getSamplingDecision.d.ts","sourceRoot":"","sources":["../../../src/utils/getSamplingDecision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAWjD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS,CA6BjF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAyBpG"} |
+3
-3
| { | ||
| "name": "@sentry/opentelemetry", | ||
| "version": "10.65.0", | ||
| "version": "10.66.0", | ||
| "description": "Official Sentry utilities for OpenTelemetry", | ||
@@ -51,4 +51,4 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
| "dependencies": { | ||
| "@sentry/conventions": "^0.15.1", | ||
| "@sentry/core": "10.65.0" | ||
| "@sentry/conventions": "^0.16.0", | ||
| "@sentry/core": "10.66.0" | ||
| }, | ||
@@ -55,0 +55,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
715925
0.38%5763
0.33%+ Added
+ Added
- Removed
- Removed
Updated
Updated