@sentry/opentelemetry 10.48.0 → 10.50.0-alpha.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/README.md +3 -6
- package/build/cjs/debug-build-ntZrglYX.js +9 -0
- package/build/cjs/debug-build-ntZrglYX.js.map +1 -0
- package/build/cjs/index.js +328 -64
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/tracingChannel.js +68 -0
- package/build/cjs/tracingChannel.js.map +1 -0
- package/build/esm/debug-build-DcLzdrV_.js +9 -0
- package/build/esm/debug-build-DcLzdrV_.js.map +1 -0
- package/build/esm/index.js +322 -60
- package/build/esm/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/tracingChannel.js +66 -0
- package/build/esm/tracingChannel.js.map +1 -0
- package/build/types/asyncLocalStorageContextManager.d.ts +31 -0
- package/build/types/asyncLocalStorageContextManager.d.ts.map +1 -0
- package/build/types/contextManager.d.ts +2 -0
- package/build/types/contextManager.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/resource.d.ts +23 -0
- package/build/types/resource.d.ts.map +1 -0
- package/build/types/sampler.d.ts.map +1 -1
- package/build/types/spanExporter.d.ts.map +1 -1
- package/build/types/trace.d.ts.map +1 -1
- package/build/types/tracingChannel.d.ts +39 -0
- package/build/types/tracingChannel.d.ts.map +1 -0
- package/build/types/utils/buildContextWithSentryScopes.d.ts +12 -0
- package/build/types/utils/buildContextWithSentryScopes.d.ts.map +1 -0
- package/build/types/utils/contextData.d.ts +7 -0
- package/build/types/utils/contextData.d.ts.map +1 -1
- package/build/types-ts3.8/asyncLocalStorageContextManager.d.ts +31 -0
- package/build/types-ts3.8/contextManager.d.ts +2 -0
- package/build/types-ts3.8/index.d.ts +2 -0
- package/build/types-ts3.8/resource.d.ts +26 -0
- package/build/types-ts3.8/tracingChannel.d.ts +39 -0
- package/build/types-ts3.8/utils/buildContextWithSentryScopes.d.ts +12 -0
- package/build/types-ts3.8/utils/contextData.d.ts +7 -0
- package/package.json +12 -4
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.50.0-alpha.0","sideEffects":false}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { tracingChannel as tracingChannel$1 } from 'node:diagnostics_channel';
|
|
2
|
+
import { context, trace } from '@opentelemetry/api';
|
|
3
|
+
import { logger } from '@sentry/core';
|
|
4
|
+
import { D as DEBUG_BUILD } from './debug-build-DcLzdrV_.js';
|
|
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
|
+
) {
|
|
27
|
+
const channel = tracingChannel$1(
|
|
28
|
+
channelNameOrInstance,
|
|
29
|
+
) ;
|
|
30
|
+
|
|
31
|
+
let lookup;
|
|
32
|
+
try {
|
|
33
|
+
const contextManager = (context )._getContextManager();
|
|
34
|
+
lookup = contextManager.getAsyncLocalStorageLookup();
|
|
35
|
+
} catch {
|
|
36
|
+
// getAsyncLocalStorageLookup may not exist if using a non-Sentry context manager
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!lookup) {
|
|
40
|
+
DEBUG_BUILD &&
|
|
41
|
+
logger.warn(
|
|
42
|
+
'[TracingChannel] Could not access OpenTelemetry AsyncLocalStorage, context propagation will not work.',
|
|
43
|
+
);
|
|
44
|
+
return channel;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
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
|
+
channel.start.bindStore(otelStorage, (data) => {
|
|
53
|
+
const span = transformStart(data);
|
|
54
|
+
|
|
55
|
+
// Store the span on data so downstream event handlers (asyncEnd, error, etc.) can access it.
|
|
56
|
+
data._sentrySpan = span;
|
|
57
|
+
|
|
58
|
+
// Return the context with the span set — this is what gets stored in AsyncLocalStorage.
|
|
59
|
+
return trace.setSpan(context.active(), span);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return channel;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { tracingChannel };
|
|
66
|
+
//# sourceMappingURL=tracingChannel.js.map
|
|
@@ -0,0 +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\ntype WithSpan<TData = object> = TData & { _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 = WithSpan<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, WithSpan<TData>> {\n const channel = nativeTracingChannel<WithSpan<TData>, WithSpan<TData>>(\n channelNameOrInstance,\n ) as unknown as OtelTracingChannel<TData, WithSpan<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: WithSpan<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,EAA8C;AAC9C,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,KAAsB;AAClE,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;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Context, ContextManager } from '@opentelemetry/api';
|
|
2
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
+
import type { AsyncLocalStorageLookup } from './contextManager';
|
|
4
|
+
/**
|
|
5
|
+
* OpenTelemetry-compatible context manager using Node.js `AsyncLocalStorage`.
|
|
6
|
+
* Semantics match `@opentelemetry/context-async-hooks` (function `bind` + `EventEmitter` patching).
|
|
7
|
+
*/
|
|
8
|
+
export declare class SentryAsyncLocalStorageContextManager implements ContextManager {
|
|
9
|
+
protected readonly _asyncLocalStorage: AsyncLocalStorage<Context>;
|
|
10
|
+
private readonly _kOtListeners;
|
|
11
|
+
private _wrapped;
|
|
12
|
+
constructor();
|
|
13
|
+
active(): Context;
|
|
14
|
+
with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(context: Context, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
|
|
15
|
+
enable(): this;
|
|
16
|
+
disable(): this;
|
|
17
|
+
bind<T>(context: Context, target: T): T;
|
|
18
|
+
/**
|
|
19
|
+
* Gets underlying AsyncLocalStorage and symbol to allow lookup of scope.
|
|
20
|
+
* This is Sentry-specific.
|
|
21
|
+
*/
|
|
22
|
+
getAsyncLocalStorageLookup(): AsyncLocalStorageLookup;
|
|
23
|
+
private _bindFunction;
|
|
24
|
+
private _bindEventEmitter;
|
|
25
|
+
private _patchRemoveListener;
|
|
26
|
+
private _patchRemoveAllListeners;
|
|
27
|
+
private _patchAddListener;
|
|
28
|
+
private _createPatchMap;
|
|
29
|
+
private _getPatchMap;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=asyncLocalStorageContextManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asyncLocalStorageContextManager.d.ts","sourceRoot":"","sources":["../../src/asyncLocalStorageContextManager.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAahE;;;GAGG;AACH,qBAAa,qCAAsC,YAAW,cAAc;IAC1E,SAAS,CAAC,QAAQ,CAAC,kBAAkB,6BAAoC;IAEzE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IACvD,OAAO,CAAC,QAAQ,CAAS;;IAMlB,MAAM,IAAI,OAAO;IAIjB,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,EACtE,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,CAAC,EACL,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC9B,GAAG,IAAI,EAAE,CAAC,GACT,UAAU,CAAC,CAAC,CAAC;IAMT,MAAM,IAAI,IAAI;IAId,OAAO,IAAI,IAAI;IAKf,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC;IAU9C;;;OAGG;IACI,0BAA0B,IAAI,uBAAuB;IAO5D,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,wBAAwB;IAiBhC,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -14,6 +14,8 @@ type ExtendedContextManagerInstance<ContextManagerInstance extends ContextManage
|
|
|
14
14
|
* import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
|
|
15
15
|
* const SentryContextManager = wrapContextManagerClass(AsyncLocalStorageContextManager);
|
|
16
16
|
* const contextManager = new SentryContextManager();
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use {@link SentryAsyncLocalStorageContextManager} instead.
|
|
17
19
|
*/
|
|
18
20
|
export declare function wrapContextManagerClass<ContextManagerInstance extends ContextManager>(ContextManagerClass: new (...args: unknown[]) => ContextManagerInstance): ExtendedContextManagerInstance<ContextManagerInstance>;
|
|
19
21
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextManager.d.ts","sourceRoot":"","sources":["../../src/contextManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"contextManager.d.ts","sourceRoot":"","sources":["../../src/contextManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKlE,MAAM,MAAM,uBAAuB,GAAG;IACpC,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC9C,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,KAAK,8BAA8B,CAAC,sBAAsB,SAAS,cAAc,IAAI,KACnF,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,sBAAsB,GAAG;IAC5B,0BAA0B,IAAI,uBAAuB,CAAC;CACvD,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,sBAAsB,SAAS,cAAc,EACnF,mBAAmB,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,sBAAsB,GACtE,8BAA8B,CAAC,sBAAsB,CAAC,CA0CxD"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -14,11 +14,13 @@ export { suppressTracing } from './utils/suppressTracing';
|
|
|
14
14
|
export { setupEventContextTrace } from './setupEventContextTrace';
|
|
15
15
|
export { setOpenTelemetryContextAsyncContextStrategy } from './asyncContextStrategy';
|
|
16
16
|
export { wrapContextManagerClass } from './contextManager';
|
|
17
|
+
export { SentryAsyncLocalStorageContextManager } from './asyncLocalStorageContextManager';
|
|
17
18
|
export type { AsyncLocalStorageLookup } from './contextManager';
|
|
18
19
|
export { SentryPropagator, shouldPropagateTraceForUrl } from './propagator';
|
|
19
20
|
export { SentrySpanProcessor } from './spanProcessor';
|
|
20
21
|
export { SentrySampler, wrapSamplingDecision } from './sampler';
|
|
21
22
|
export { openTelemetrySetupCheck } from './utils/setupCheck';
|
|
23
|
+
export { getSentryResource } from './resource';
|
|
22
24
|
export { withStreamedSpan } from '@sentry/core';
|
|
23
25
|
export { getClient } from '@sentry/core';
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2CAA2C,EAAE,MAAM,sBAAsB,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAm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ribute = [string, AttributeValue | undefined];
|
|
3
|
+
/**
|
|
4
|
+
* Minimal Resource implementation that satisfies the OpenTelemetry Resource interface
|
|
5
|
+
* used by BasicTracerProvider, without depending on `@opentelemetry/resources`.
|
|
6
|
+
*/
|
|
7
|
+
declare class SentryResource {
|
|
8
|
+
private _attributes;
|
|
9
|
+
constructor(attributes: Attributes);
|
|
10
|
+
get attributes(): Attributes;
|
|
11
|
+
merge(other: SentryResource | null): SentryResource;
|
|
12
|
+
getRawAttributes(): RawResourceAttribute[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns a Resource for use in Sentry's OpenTelemetry TracerProvider setup.
|
|
16
|
+
*
|
|
17
|
+
* Combines the default OTel SDK telemetry attributes with Sentry-specific
|
|
18
|
+
* service attributes, equivalent to what was previously done via:
|
|
19
|
+
* `defaultResource().merge(resourceFromAttributes({ ... }))`
|
|
20
|
+
*/
|
|
21
|
+
export declare function getSentryResource(serviceName: string): SentryResource;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAYrE,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC;AAEjE;;;GAGG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,WAAW,CAAa;gBAEb,UAAU,EAAE,UAAU;IAIzC,IAAW,UAAU,IAAI,UAAU,CAElC;IAEM,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,GAAG,cAAc;IAOnD,gBAAgB,IAAI,oBAAoB,EAAE;CAGlD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAUrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampler.d.ts","sourceRoot":"","sources":["../../src/sampler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2C,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAsB,QAAQ,EAAS,MAAM,oBAAoB,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAOjE,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA4B3D;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC3C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,gBAAgB,CAAU;gBAEf,MAAM,EAAE,MAAM;IAMjC,kBAAkB;IACX,YAAY,CACjB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,OAAO,GACd,cAAc;
|
|
1
|
+
{"version":3,"file":"sampler.d.ts","sourceRoot":"","sources":["../../src/sampler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2C,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAsB,QAAQ,EAAS,MAAM,oBAAoB,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAOjE,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA4B3D;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC3C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,gBAAgB,CAAU;gBAEf,MAAM,EAAE,MAAM;IAMjC,k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I,EAAE,YAAY,GAAG,IAAI;IAoCvC;;;;OAIG;IACI,KAAK,IAAI,IAAI;IA4BpB;;;OAGG;IACI,KAAK,IAAI,IAAI;IAMpB;;;;;;;;OAQG;IACH,OAAO,CAAC,UAAU;
|
|
1
|
+
{"version":3,"file":"spanExporter.d.ts","sourceRoot":"","sources":["../../src/spanExporter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,KAAK,EAKV,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AAqCtB;;GAEG;AACH,qBAAa,kBAAkB;IAiB7B,OAAO,CAAC,oBAAoB,CAAqC;IACjE,OAAO,CAAC,uBAAuB,CAAS;IACxC,OAAO,CAAC,mBAAmB,CAA4C;IACvE,OAAO,CAAC,wBAAwB,CAAS;IAGzC,OAAO,CAAC,UAAU,CAAsB;IAExC,OAAO,CAAC,eAAe,CAA8B;gBAElC,OAAO,CAAC,EAAE;QAC3B,4IAA4I;QAC5I,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IASD;;;OAGG;IACI,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAoCvC;;;;OAIG;IACI,KAAK,IAAI,IAAI;IA4BpB;;;OAGG;IACI,KAAK,IAAI,IAAI;IAMpB;;;;;;;;OAQG;IACH,OAAO,CAAC,UAAU;IAsDlB,kEAAkE;IAClE,OAAO,CAAC,mBAAmB;IAU3B,4FAA4F;IAC5F,OAAO,CAAC,uCAAuC;IAI/C,wDAAwD;IACxD,OAAO,CAAC,sBAAsB;CAK/B;AAYD,+BAA+B;AAC/B,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAoEjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,IAAI,EAA+C,MAAM,oBAAoB,CAAC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GAAG,CAAC,CAEvG;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAoBrD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GACX,CAAC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,CAUvF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored and adapted from https://github.com/logaretm/otel-tracing-channel
|
|
3
|
+
*
|
|
4
|
+
* Creates a TracingChannel with proper OpenTelemetry context propagation
|
|
5
|
+
* using Node.js diagnostic_channel's `bindStore` mechanism.
|
|
6
|
+
*/
|
|
7
|
+
import type { TracingChannel, TracingChannelSubscribers } from 'node:diagnostics_channel';
|
|
8
|
+
import type { Span } from '@opentelemetry/api';
|
|
9
|
+
/**
|
|
10
|
+
* Transform function that creates a span from the channel data.
|
|
11
|
+
*/
|
|
12
|
+
export type OtelTracingChannelTransform<TData = object> = (data: TData) => Span;
|
|
13
|
+
type WithSpan<TData = object> = TData & {
|
|
14
|
+
_sentrySpan?: Span;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A TracingChannel whose `subscribe` / `unsubscribe` accept partial subscriber
|
|
18
|
+
* objects — you only need to provide handlers for the events you care about.
|
|
19
|
+
*/
|
|
20
|
+
export interface OtelTracingChannel<TData extends object = object, TDataWithSpan extends object = WithSpan<TData>> extends Omit<TracingChannel<TData, TDataWithSpan>, 'subscribe' | 'unsubscribe'> {
|
|
21
|
+
subscribe(subscribers: Partial<TracingChannelSubscribers<TDataWithSpan>>): void;
|
|
22
|
+
unsubscribe(subscribers: Partial<TracingChannelSubscribers<TDataWithSpan>>): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new tracing channel with proper OTel context propagation.
|
|
26
|
+
*
|
|
27
|
+
* When the channel's `tracePromise` / `traceSync` / `traceCallback` is called,
|
|
28
|
+
* the `transformStart` function runs inside `bindStore` so that:
|
|
29
|
+
* 1. A new span is created from the channel data.
|
|
30
|
+
* 2. The span is set on the OTel context stored in AsyncLocalStorage.
|
|
31
|
+
* 3. Downstream code (including Sentry's span processor) sees the correct parent.
|
|
32
|
+
*
|
|
33
|
+
* @param channelNameOrInstance - Either a channel name string or an existing TracingChannel instance.
|
|
34
|
+
* @param transformStart - Function that creates an OpenTelemetry span from the channel data.
|
|
35
|
+
* @returns The tracing channel with OTel context bound.
|
|
36
|
+
*/
|
|
37
|
+
export declare function tracingChannel<TData extends object = object>(channelNameOrInstance: string, transformStart: OtelTracingChannelTransform<TData>): OtelTracingChannel<TData, WithSpan<TData>>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=tracingChannel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracingChannel.d.ts","sourceRoot":"","sources":["../../src/tracingChannel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE1F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAO/C;;GAEG;AACH,MAAM,MAAM,2BAA2B,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;AAEhF,KAAK,QAAQ,CAAC,KAAK,GAAG,MAAM,IAAI,KAAK,GAAG;IAAE,WAAW,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CACjC,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,aAAa,SAAS,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAC9C,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,aAAa,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC;IAC/E,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,yBAAyB,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC;IAChF,WAAW,CAAC,WAAW,EAAE,OAAO,CAAC,yBAAyB,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC;CACnF;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAC1D,qBAAqB,EAAE,MAAM,EAC7B,cAAc,EAAE,2BAA2B,CAAC,KAAK,CAAC,GACjD,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAqC5C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Context } from '@opentelemetry/api';
|
|
2
|
+
/**
|
|
3
|
+
* Merge Sentry scopes into an OpenTelemetry {@link Context} and apply trace-context adjustments
|
|
4
|
+
* used by Sentry OpenTelemetry context manager(s).
|
|
5
|
+
*
|
|
6
|
+
* @param context - Context passed into `ContextManager.with`.
|
|
7
|
+
* @param activeContext - Context that was active before entering `with` (e.g. `this.active()`), used
|
|
8
|
+
* to restore the parent span when the incoming span is marked ignored for children.
|
|
9
|
+
* @returns A new context ready for `super.with` / `AsyncLocalStorage.run`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildContextWithSentryScopes(context: Context, activeContext: Context): Context;
|
|
12
|
+
//# sourceMappingURL=buildContextWithSentryScopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildContextWithSentryScopes.d.ts","sourceRoot":"","sources":["../../../src/utils/buildContextWithSentryScopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAYlD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,OAAO,CAkC9F"}
|
|
@@ -14,10 +14,17 @@ export declare function setScopesOnContext(context: Context, scopes: CurrentScop
|
|
|
14
14
|
/**
|
|
15
15
|
* Set the context on the scope so we can later look it up.
|
|
16
16
|
* We need this to get the context from the scope in the `trace` functions.
|
|
17
|
+
*
|
|
18
|
+
* We use WeakRef to avoid a circular reference between the scope and the context.
|
|
19
|
+
* The context holds scopes (via SENTRY_SCOPES_CONTEXT_KEY), and if the scope held
|
|
20
|
+
* a strong reference back to the context, neither could be garbage collected even
|
|
21
|
+
* when the context is no longer reachable from application code (e.g., after a
|
|
22
|
+
* request completes but pooled connections retain patched callbacks).
|
|
17
23
|
*/
|
|
18
24
|
export declare function setContextOnScope(scope: Scope, context: Context): void;
|
|
19
25
|
/**
|
|
20
26
|
* Get the context related to a scope.
|
|
27
|
+
* Returns undefined if the context has been garbage collected (when WeakRef is used).
|
|
21
28
|
*/
|
|
22
29
|
export declare function getContextFromScope(scope: Scope): Context | undefined;
|
|
23
30
|
//# sourceMappingURL=contextData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextData.d.ts","sourceRoot":"","sources":["../../../src/utils/contextData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"contextData.d.ts","sourceRoot":"","sources":["../../../src/utils/contextData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQ9C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAEhF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAEnF;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAEtE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAErE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Context, ContextManager } from '@opentelemetry/api';
|
|
2
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
+
import { AsyncLocalStorageLookup } from './contextManager';
|
|
4
|
+
/**
|
|
5
|
+
* OpenTelemetry-compatible context manager using Node.js `AsyncLocalStorage`.
|
|
6
|
+
* Semantics match `@opentelemetry/context-async-hooks` (function `bind` + `EventEmitter` patching).
|
|
7
|
+
*/
|
|
8
|
+
export declare class SentryAsyncLocalStorageContextManager implements ContextManager {
|
|
9
|
+
protected readonly _asyncLocalStorage: AsyncLocalStorage<Context>;
|
|
10
|
+
private readonly _kOtListeners;
|
|
11
|
+
private _wrapped;
|
|
12
|
+
constructor();
|
|
13
|
+
active(): Context;
|
|
14
|
+
with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(context: Context, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
|
|
15
|
+
enable(): this;
|
|
16
|
+
disable(): this;
|
|
17
|
+
bind<T>(context: Context, target: T): T;
|
|
18
|
+
/**
|
|
19
|
+
* Gets underlying AsyncLocalStorage and symbol to allow lookup of scope.
|
|
20
|
+
* This is Sentry-specific.
|
|
21
|
+
*/
|
|
22
|
+
getAsyncLocalStorageLookup(): AsyncLocalStorageLookup;
|
|
23
|
+
private _bindFunction;
|
|
24
|
+
private _bindEventEmitter;
|
|
25
|
+
private _patchRemoveListener;
|
|
26
|
+
private _patchRemoveAllListeners;
|
|
27
|
+
private _patchAddListener;
|
|
28
|
+
private _createPatchMap;
|
|
29
|
+
private _getPatchMap;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=asyncLocalStorageContextManager.d.ts.map
|
|
@@ -14,6 +14,8 @@ type ExtendedContextManagerInstance<ContextManagerInstance extends ContextManage
|
|
|
14
14
|
* import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
|
|
15
15
|
* const SentryContextManager = wrapContextManagerClass(AsyncLocalStorageContextManager);
|
|
16
16
|
* const contextManager = new SentryContextManager();
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use {@link SentryAsyncLocalStorageContextManager} instead.
|
|
17
19
|
*/
|
|
18
20
|
export declare function wrapContextManagerClass<ContextManagerInstance extends ContextManager>(ContextManagerClass: new (...args: unknown[]) => ContextManagerInstance): ExtendedContextManagerInstance<ContextManagerInstance>;
|
|
19
21
|
export {};
|
|
@@ -14,11 +14,13 @@ export { suppressTracing } from './utils/suppressTracing';
|
|
|
14
14
|
export { setupEventContextTrace } from './setupEventContextTrace';
|
|
15
15
|
export { setOpenTelemetryContextAsyncContextStrategy } from './asyncContextStrategy';
|
|
16
16
|
export { wrapContextManagerClass } from './contextManager';
|
|
17
|
+
export { SentryAsyncLocalStorageContextManager } from './asyncLocalStorageContextManager';
|
|
17
18
|
export { AsyncLocalStorageLookup } from './contextManager';
|
|
18
19
|
export { SentryPropagator, shouldPropagateTraceForUrl } from './propagator';
|
|
19
20
|
export { SentrySpanProcessor } from './spanProcessor';
|
|
20
21
|
export { SentrySampler, wrapSamplingDecision } from './sampler';
|
|
21
22
|
export { openTelemetrySetupCheck } from './utils/setupCheck';
|
|
23
|
+
export { getSentryResource } from './resource';
|
|
22
24
|
export { withStreamedSpan } from '@sentry/core';
|
|
23
25
|
export { getClient } from '@sentry/core';
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Attributes, AttributeValue } from '@opentelemetry/api';
|
|
2
|
+
type RawResourceAttribute = [
|
|
3
|
+
string,
|
|
4
|
+
AttributeValue | undefined
|
|
5
|
+
];
|
|
6
|
+
/**
|
|
7
|
+
* Minimal Resource implementation that satisfies the OpenTelemetry Resource interface
|
|
8
|
+
* used by BasicTracerProvider, without depending on `@opentelemetry/resources`.
|
|
9
|
+
*/
|
|
10
|
+
declare class SentryResource {
|
|
11
|
+
private _attributes;
|
|
12
|
+
constructor(attributes: Attributes);
|
|
13
|
+
readonly attributes: Attributes;
|
|
14
|
+
merge(other: SentryResource | null): SentryResource;
|
|
15
|
+
getRawAttributes(): RawResourceAttribute[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns a Resource for use in Sentry's OpenTelemetry TracerProvider setup.
|
|
19
|
+
*
|
|
20
|
+
* Combines the default OTel SDK telemetry attributes with Sentry-specific
|
|
21
|
+
* service attributes, equivalent to what was previously done via:
|
|
22
|
+
* `defaultResource().merge(resourceFromAttributes({ ... }))`
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSentryResource(serviceName: string): SentryResource;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored and adapted from https://github.com/logaretm/otel-tracing-channel
|
|
3
|
+
*
|
|
4
|
+
* Creates a TracingChannel with proper OpenTelemetry context propagation
|
|
5
|
+
* using Node.js diagnostic_channel's `bindStore` mechanism.
|
|
6
|
+
*/
|
|
7
|
+
import { TracingChannel, TracingChannelSubscribers } from 'node:diagnostics_channel';
|
|
8
|
+
import { Span } from '@opentelemetry/api';
|
|
9
|
+
/**
|
|
10
|
+
* Transform function that creates a span from the channel data.
|
|
11
|
+
*/
|
|
12
|
+
export type OtelTracingChannelTransform<TData = object> = (data: TData) => Span;
|
|
13
|
+
type WithSpan<TData = object> = TData & {
|
|
14
|
+
_sentrySpan?: Span;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A TracingChannel whose `subscribe` / `unsubscribe` accept partial subscriber
|
|
18
|
+
* objects — you only need to provide handlers for the events you care about.
|
|
19
|
+
*/
|
|
20
|
+
export interface OtelTracingChannel<TData extends object = object, TDataWithSpan extends object = WithSpan<TData>> extends Pick<TracingChannel<TData, TDataWithSpan>, Exclude<keyof TracingChannel<TData, TDataWithSpan>, 'subscribe' | 'unsubscribe'>> {
|
|
21
|
+
subscribe(subscribers: Partial<TracingChannelSubscribers<TDataWithSpan>>): void;
|
|
22
|
+
unsubscribe(subscribers: Partial<TracingChannelSubscribers<TDataWithSpan>>): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new tracing channel with proper OTel context propagation.
|
|
26
|
+
*
|
|
27
|
+
* When the channel's `tracePromise` / `traceSync` / `traceCallback` is called,
|
|
28
|
+
* the `transformStart` function runs inside `bindStore` so that:
|
|
29
|
+
* 1. A new span is created from the channel data.
|
|
30
|
+
* 2. The span is set on the OTel context stored in AsyncLocalStorage.
|
|
31
|
+
* 3. Downstream code (including Sentry's span processor) sees the correct parent.
|
|
32
|
+
*
|
|
33
|
+
* @param channelNameOrInstance - Either a channel name string or an existing TracingChannel instance.
|
|
34
|
+
* @param transformStart - Function that creates an OpenTelemetry span from the channel data.
|
|
35
|
+
* @returns The tracing channel with OTel context bound.
|
|
36
|
+
*/
|
|
37
|
+
export declare function tracingChannel<TData extends object = object>(channelNameOrInstance: string, transformStart: OtelTracingChannelTransform<TData>): OtelTracingChannel<TData, WithSpan<TData>>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=tracingChannel.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context } from '@opentelemetry/api';
|
|
2
|
+
/**
|
|
3
|
+
* Merge Sentry scopes into an OpenTelemetry {@link Context} and apply trace-context adjustments
|
|
4
|
+
* used by Sentry OpenTelemetry context manager(s).
|
|
5
|
+
*
|
|
6
|
+
* @param context - Context passed into `ContextManager.with`.
|
|
7
|
+
* @param activeContext - Context that was active before entering `with` (e.g. `this.active()`), used
|
|
8
|
+
* to restore the parent span when the incoming span is marked ignored for children.
|
|
9
|
+
* @returns A new context ready for `super.with` / `AsyncLocalStorage.run`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildContextWithSentryScopes(context: Context, activeContext: Context): Context;
|
|
12
|
+
//# sourceMappingURL=buildContextWithSentryScopes.d.ts.map
|
|
@@ -14,10 +14,17 @@ export declare function setScopesOnContext(context: Context, scopes: CurrentScop
|
|
|
14
14
|
/**
|
|
15
15
|
* Set the context on the scope so we can later look it up.
|
|
16
16
|
* We need this to get the context from the scope in the `trace` functions.
|
|
17
|
+
*
|
|
18
|
+
* We use WeakRef to avoid a circular reference between the scope and the context.
|
|
19
|
+
* The context holds scopes (via SENTRY_SCOPES_CONTEXT_KEY), and if the scope held
|
|
20
|
+
* a strong reference back to the context, neither could be garbage collected even
|
|
21
|
+
* when the context is no longer reachable from application code (e.g., after a
|
|
22
|
+
* request completes but pooled connections retain patched callbacks).
|
|
17
23
|
*/
|
|
18
24
|
export declare function setContextOnScope(scope: Scope, context: Context): void;
|
|
19
25
|
/**
|
|
20
26
|
* Get the context related to a scope.
|
|
27
|
+
* Returns undefined if the context has been garbage collected (when WeakRef is used).
|
|
21
28
|
*/
|
|
22
29
|
export declare function getContextFromScope(scope: Scope): Context | undefined;
|
|
23
30
|
//# sourceMappingURL=contextData.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/opentelemetry",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.50.0-alpha.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",
|
|
@@ -26,6 +26,16 @@
|
|
|
26
26
|
"types": "./build/types/index.d.ts",
|
|
27
27
|
"default": "./build/cjs/index.js"
|
|
28
28
|
}
|
|
29
|
+
},
|
|
30
|
+
"./tracing-channel": {
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./build/types/tracingChannel.d.ts",
|
|
33
|
+
"default": "./build/esm/tracingChannel.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./build/types/tracingChannel.d.ts",
|
|
37
|
+
"default": "./build/cjs/tracingChannel.js"
|
|
38
|
+
}
|
|
29
39
|
}
|
|
30
40
|
},
|
|
31
41
|
"typesVersions": {
|
|
@@ -39,18 +49,16 @@
|
|
|
39
49
|
"access": "public"
|
|
40
50
|
},
|
|
41
51
|
"dependencies": {
|
|
42
|
-
"@sentry/core": "10.
|
|
52
|
+
"@sentry/core": "10.50.0-alpha.0"
|
|
43
53
|
},
|
|
44
54
|
"peerDependencies": {
|
|
45
55
|
"@opentelemetry/api": "^1.9.0",
|
|
46
|
-
"@opentelemetry/context-async-hooks": "^1.30.1 || ^2.1.0",
|
|
47
56
|
"@opentelemetry/core": "^1.30.1 || ^2.1.0",
|
|
48
57
|
"@opentelemetry/sdk-trace-base": "^1.30.1 || ^2.1.0",
|
|
49
58
|
"@opentelemetry/semantic-conventions": "^1.39.0"
|
|
50
59
|
},
|
|
51
60
|
"devDependencies": {
|
|
52
61
|
"@opentelemetry/api": "^1.9.1",
|
|
53
|
-
"@opentelemetry/context-async-hooks": "^2.6.1",
|
|
54
62
|
"@opentelemetry/core": "^2.6.1",
|
|
55
63
|
"@opentelemetry/sdk-trace-base": "^2.6.1",
|
|
56
64
|
"@opentelemetry/semantic-conventions": "^1.40.0"
|