@sentry/opentelemetry 10.53.1 → 10.55.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.
@@ -1,64 +1,30 @@
1
1
  import { tracingChannel as tracingChannel$1 } from 'node:diagnostics_channel';
2
2
  import { context, trace } from '@opentelemetry/api';
3
3
  import { logger } from '@sentry/core';
4
- import { D as DEBUG_BUILD } from './debug-build-DcLzdrV_.js';
4
+ import { D as DEBUG_BUILD } from './debug-build-B98wrZ1j.js';
5
5
 
6
- /**
7
- * Transform function that creates a span from the channel data.
8
- */
9
-
10
- /**
11
- * Creates a new tracing channel with proper OTel context propagation.
12
- *
13
- * When the channel's `tracePromise` / `traceSync` / `traceCallback` is called,
14
- * the `transformStart` function runs inside `bindStore` so that:
15
- * 1. A new span is created from the channel data.
16
- * 2. The span is set on the OTel context stored in AsyncLocalStorage.
17
- * 3. Downstream code (including Sentry's span processor) sees the correct parent.
18
- *
19
- * @param channelNameOrInstance - Either a channel name string or an existing TracingChannel instance.
20
- * @param transformStart - Function that creates an OpenTelemetry span from the channel data.
21
- * @returns The tracing channel with OTel context bound.
22
- */
23
- function tracingChannel(
24
- channelNameOrInstance,
25
- transformStart,
26
- ) {
6
+ function tracingChannel(channelNameOrInstance, transformStart) {
27
7
  const channel = tracingChannel$1(
28
- channelNameOrInstance,
29
- ) ;
30
-
8
+ channelNameOrInstance
9
+ );
31
10
  let lookup;
32
11
  try {
33
- const contextManager = (context )._getContextManager();
12
+ const contextManager = context._getContextManager();
34
13
  lookup = contextManager.getAsyncLocalStorageLookup();
35
14
  } catch {
36
- // getAsyncLocalStorageLookup may not exist if using a non-Sentry context manager
37
15
  }
38
-
39
16
  if (!lookup) {
40
- DEBUG_BUILD &&
41
- logger.warn(
42
- '[TracingChannel] Could not access OpenTelemetry AsyncLocalStorage, context propagation will not work.',
43
- );
17
+ DEBUG_BUILD && logger.warn(
18
+ "[TracingChannel] Could not access OpenTelemetry AsyncLocalStorage, context propagation will not work."
19
+ );
44
20
  return channel;
45
21
  }
46
-
47
22
  const otelStorage = lookup.asyncLocalStorage;
48
-
49
- // Bind the start channel so that each trace invocation runs the transform
50
- // and stores the resulting context (with span) in AsyncLocalStorage.
51
- // @ts-expect-error bindStore types don't account for AsyncLocalStorage of a different generic type
52
23
  channel.start.bindStore(otelStorage, (data) => {
53
24
  const span = transformStart(data);
54
-
55
- // Store the span on data so downstream event handlers (asyncEnd, error, etc.) can access it.
56
25
  data._sentrySpan = span;
57
-
58
- // Return the context with the span set — this is what gets stored in AsyncLocalStorage.
59
26
  return trace.setSpan(context.active(), span);
60
27
  });
61
-
62
28
  return channel;
63
29
  }
64
30
 
@@ -1 +1 @@
1
- {"version":3,"file":"tracingChannel.js","sources":["../../src/tracingChannel.ts"],"sourcesContent":["/**\n * Vendored and adapted from https://github.com/logaretm/otel-tracing-channel\n *\n * Creates a TracingChannel with proper OpenTelemetry context propagation\n * using Node.js diagnostic_channel's `bindStore` mechanism.\n */\nimport type { TracingChannel, TracingChannelSubscribers } from 'node:diagnostics_channel';\nimport { tracingChannel as nativeTracingChannel } from 'node:diagnostics_channel';\nimport type { Span } from '@opentelemetry/api';\nimport { context, trace } from '@opentelemetry/api';\nimport { logger } from '@sentry/core';\nimport type { SentryAsyncLocalStorageContextManager } from './asyncLocalStorageContextManager';\nimport type { AsyncLocalStorageLookup } from './contextManager';\nimport { DEBUG_BUILD } from './debug-build';\n\n/**\n * Transform function that creates a span from the channel data.\n */\nexport type OtelTracingChannelTransform<TData = object> = (data: TData) => Span;\n\nexport type TracingChannelContextWithSpan<TContext extends object = object> = TContext & { _sentrySpan?: Span };\n\n/**\n * A TracingChannel whose `subscribe` / `unsubscribe` accept partial subscriber\n * objects — you only need to provide handlers for the events you care about.\n */\nexport interface OtelTracingChannel<\n TData extends object = object,\n TDataWithSpan extends object = TracingChannelContextWithSpan<TData>,\n> extends Omit<TracingChannel<TData, TDataWithSpan>, 'subscribe' | 'unsubscribe'> {\n subscribe(subscribers: Partial<TracingChannelSubscribers<TDataWithSpan>>): void;\n unsubscribe(subscribers: Partial<TracingChannelSubscribers<TDataWithSpan>>): void;\n}\n\ninterface ContextApi {\n _getContextManager(): SentryAsyncLocalStorageContextManager;\n}\n\n/**\n * Creates a new tracing channel with proper OTel context propagation.\n *\n * When the channel's `tracePromise` / `traceSync` / `traceCallback` is called,\n * the `transformStart` function runs inside `bindStore` so that:\n * 1. A new span is created from the channel data.\n * 2. The span is set on the OTel context stored in AsyncLocalStorage.\n * 3. Downstream code (including Sentry's span processor) sees the correct parent.\n *\n * @param channelNameOrInstance - Either a channel name string or an existing TracingChannel instance.\n * @param transformStart - Function that creates an OpenTelemetry span from the channel data.\n * @returns The tracing channel with OTel context bound.\n */\nexport function tracingChannel<TData extends object = object>(\n channelNameOrInstance: string,\n transformStart: OtelTracingChannelTransform<TData>,\n): OtelTracingChannel<TData, TracingChannelContextWithSpan<TData>> {\n const channel = nativeTracingChannel<TracingChannelContextWithSpan<TData>, TracingChannelContextWithSpan<TData>>(\n channelNameOrInstance,\n ) as unknown as OtelTracingChannel<TData, TracingChannelContextWithSpan<TData>>;\n\n let lookup: AsyncLocalStorageLookup | undefined;\n try {\n const contextManager = (context as unknown as ContextApi)._getContextManager();\n lookup = contextManager.getAsyncLocalStorageLookup();\n } catch {\n // getAsyncLocalStorageLookup may not exist if using a non-Sentry context manager\n }\n\n if (!lookup) {\n DEBUG_BUILD &&\n logger.warn(\n '[TracingChannel] Could not access OpenTelemetry AsyncLocalStorage, context propagation will not work.',\n );\n return channel;\n }\n\n const otelStorage = lookup.asyncLocalStorage;\n\n // Bind the start channel so that each trace invocation runs the transform\n // and stores the resulting context (with span) in AsyncLocalStorage.\n // @ts-expect-error bindStore types don't account for AsyncLocalStorage of a different generic type\n channel.start.bindStore(otelStorage, (data: TracingChannelContextWithSpan<TData>) => {\n const span = transformStart(data);\n\n // Store the span on data so downstream event handlers (asyncEnd, error, etc.) can access it.\n data._sentrySpan = span;\n\n // Return the context with the span set — this is what gets stored in AsyncLocalStorage.\n return trace.setSpan(context.active(), span);\n });\n\n return channel;\n}\n"],"names":["nativeTracingChannel"],"mappings":";;;;;AAeA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc;AAC9B,EAAE,qBAAqB;AACvB,EAAE,cAAc;AAChB,EAAmE;AACnE,EAAE,MAAM,OAAA,GAAUA,gBAAoB;AACtC,IAAI,qBAAqB;AACzB,GAAE;;AAEF,EAAE,IAAI,MAAM;AACZ,EAAE,IAAI;AACN,IAAI,MAAM,iBAAiB,CAAC,UAAkC,kBAAkB,EAAE;AAClF,IAAI,SAAS,cAAc,CAAC,0BAA0B,EAAE;AACxD,EAAE,EAAE,MAAM;AACV;AACA,EAAE;;AAEF,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAI,WAAA;AACJ,MAAM,MAAM,CAAC,IAAI;AACjB,QAAQ,uGAAuG;AAC/G,OAAO;AACP,IAAI,OAAO,OAAO;AAClB,EAAE;;AAEF,EAAE,MAAM,WAAA,GAAc,MAAM,CAAC,iBAAiB;;AAE9C;AACA;AACA;AACA,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,IAAI,KAA2C;AACvF,IAAI,MAAM,IAAA,GAAO,cAAc,CAAC,IAAI,CAAC;;AAErC;AACA,IAAI,IAAI,CAAC,WAAA,GAAc,IAAI;;AAE3B;AACA,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC;AAChD,EAAE,CAAC,CAAC;;AAEJ,EAAE,OAAO,OAAO;AAChB;;;;"}
1
+ {"version":3,"file":"tracingChannel.js","sources":["../../src/tracingChannel.ts"],"sourcesContent":["/**\n * Vendored and adapted from https://github.com/logaretm/otel-tracing-channel\n *\n * Creates a TracingChannel with proper OpenTelemetry context propagation\n * using Node.js diagnostic_channel's `bindStore` mechanism.\n */\nimport type { TracingChannel, TracingChannelSubscribers } from 'node:diagnostics_channel';\nimport { tracingChannel as nativeTracingChannel } from 'node:diagnostics_channel';\nimport type { Span } from '@opentelemetry/api';\nimport { context, trace } from '@opentelemetry/api';\nimport { logger } from '@sentry/core';\nimport type { SentryAsyncLocalStorageContextManager } from './asyncLocalStorageContextManager';\nimport type { AsyncLocalStorageLookup } from './contextManager';\nimport { DEBUG_BUILD } from './debug-build';\n\n/**\n * Transform function that creates a span from the channel data.\n */\nexport type OtelTracingChannelTransform<TData = object> = (data: TData) => Span;\n\nexport type TracingChannelContextWithSpan<TContext extends object = object> = TContext & { _sentrySpan?: Span };\n\n/**\n * A TracingChannel whose `subscribe` / `unsubscribe` accept partial subscriber\n * objects — you only need to provide handlers for the events you care about.\n */\nexport interface OtelTracingChannel<\n TData extends object = object,\n TDataWithSpan extends object = TracingChannelContextWithSpan<TData>,\n> extends Omit<TracingChannel<TData, TDataWithSpan>, 'subscribe' | 'unsubscribe'> {\n subscribe(subscribers: Partial<TracingChannelSubscribers<TDataWithSpan>>): void;\n unsubscribe(subscribers: Partial<TracingChannelSubscribers<TDataWithSpan>>): void;\n}\n\ninterface ContextApi {\n _getContextManager(): SentryAsyncLocalStorageContextManager;\n}\n\n/**\n * Creates a new tracing channel with proper OTel context propagation.\n *\n * When the channel's `tracePromise` / `traceSync` / `traceCallback` is called,\n * the `transformStart` function runs inside `bindStore` so that:\n * 1. A new span is created from the channel data.\n * 2. The span is set on the OTel context stored in AsyncLocalStorage.\n * 3. Downstream code (including Sentry's span processor) sees the correct parent.\n *\n * @param channelNameOrInstance - Either a channel name string or an existing TracingChannel instance.\n * @param transformStart - Function that creates an OpenTelemetry span from the channel data.\n * @returns The tracing channel with OTel context bound.\n */\nexport function tracingChannel<TData extends object = object>(\n channelNameOrInstance: string,\n transformStart: OtelTracingChannelTransform<TData>,\n): OtelTracingChannel<TData, TracingChannelContextWithSpan<TData>> {\n const channel = nativeTracingChannel<TracingChannelContextWithSpan<TData>, TracingChannelContextWithSpan<TData>>(\n channelNameOrInstance,\n ) as unknown as OtelTracingChannel<TData, TracingChannelContextWithSpan<TData>>;\n\n let lookup: AsyncLocalStorageLookup | undefined;\n try {\n const contextManager = (context as unknown as ContextApi)._getContextManager();\n lookup = contextManager.getAsyncLocalStorageLookup();\n } catch {\n // getAsyncLocalStorageLookup may not exist if using a non-Sentry context manager\n }\n\n if (!lookup) {\n DEBUG_BUILD &&\n logger.warn(\n '[TracingChannel] Could not access OpenTelemetry AsyncLocalStorage, context propagation will not work.',\n );\n return channel;\n }\n\n const otelStorage = lookup.asyncLocalStorage;\n\n // Bind the start channel so that each trace invocation runs the transform\n // and stores the resulting context (with span) in AsyncLocalStorage.\n // @ts-expect-error bindStore types don't account for AsyncLocalStorage of a different generic type\n channel.start.bindStore(otelStorage, (data: TracingChannelContextWithSpan<TData>) => {\n const span = transformStart(data);\n\n // Store the span on data so downstream event handlers (asyncEnd, error, etc.) can access it.\n data._sentrySpan = span;\n\n // Return the context with the span set — this is what gets stored in AsyncLocalStorage.\n return trace.setSpan(context.active(), span);\n });\n\n return channel;\n}\n"],"names":["nativeTracingChannel"],"mappings":";;;;;AAmDO,SAAS,cAAA,CACd,uBACA,cAAA,EACiE;AACjE,EAAA,MAAM,OAAA,GAAUA,gBAAA;AAAA,IACd;AAAA,GACF;AAEA,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAM,cAAA,GAAkB,QAAkC,kBAAA,EAAmB;AAC7E,IAAA,MAAA,GAAS,eAAe,0BAAA,EAA2B;AAAA,EACrD,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,WAAA,IACE,MAAA,CAAO,IAAA;AAAA,MACL;AAAA,KACF;AACF,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,MAAM,cAAc,MAAA,CAAO,iBAAA;AAK3B,EAAA,OAAA,CAAQ,KAAA,CAAM,SAAA,CAAU,WAAA,EAAa,CAAC,IAAA,KAA+C;AACnF,IAAA,MAAM,IAAA,GAAO,eAAe,IAAI,CAAA;AAGhC,IAAA,IAAA,CAAK,WAAA,GAAc,IAAA;AAGnB,IAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,OAAA,CAAQ,MAAA,IAAU,IAAI,CAAA;AAAA,EAC7C,CAAC,CAAA;AAED,EAAA,OAAO,OAAA;AACT;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/opentelemetry",
3
- "version": "10.53.1",
3
+ "version": "10.55.0",
4
4
  "description": "Official Sentry utilities for OpenTelemetry",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/opentelemetry",
@@ -65,7 +65,7 @@
65
65
  "access": "public"
66
66
  },
67
67
  "dependencies": {
68
- "@sentry/core": "10.53.1"
68
+ "@sentry/core": "10.55.0"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@opentelemetry/api": "^1.9.0",
@@ -1,9 +0,0 @@
1
- /**
2
- * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
3
- *
4
- * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
5
- */
6
- const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
7
-
8
- exports.DEBUG_BUILD = DEBUG_BUILD;
9
- //# sourceMappingURL=debug-build-ntZrglYX.js.map