@sentry/opentelemetry 10.47.0 → 10.49.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.
Files changed (32) hide show
  1. package/README.md +3 -6
  2. package/build/cjs/index.js +399 -72
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/esm/index.js +401 -77
  5. package/build/esm/index.js.map +1 -1
  6. package/build/esm/package.json +1 -1
  7. package/build/types/asyncLocalStorageContextManager.d.ts +31 -0
  8. package/build/types/asyncLocalStorageContextManager.d.ts.map +1 -0
  9. package/build/types/constants.d.ts +12 -0
  10. package/build/types/constants.d.ts.map +1 -1
  11. package/build/types/contextManager.d.ts +2 -0
  12. package/build/types/contextManager.d.ts.map +1 -1
  13. package/build/types/index.d.ts +3 -0
  14. package/build/types/index.d.ts.map +1 -1
  15. package/build/types/resource.d.ts +23 -0
  16. package/build/types/resource.d.ts.map +1 -0
  17. package/build/types/sampler.d.ts +4 -1
  18. package/build/types/sampler.d.ts.map +1 -1
  19. package/build/types/spanProcessor.d.ts.map +1 -1
  20. package/build/types/utils/buildContextWithSentryScopes.d.ts +12 -0
  21. package/build/types/utils/buildContextWithSentryScopes.d.ts.map +1 -0
  22. package/build/types/utils/contextData.d.ts +7 -0
  23. package/build/types/utils/contextData.d.ts.map +1 -1
  24. package/build/types-ts3.8/asyncLocalStorageContextManager.d.ts +31 -0
  25. package/build/types-ts3.8/constants.d.ts +12 -0
  26. package/build/types-ts3.8/contextManager.d.ts +2 -0
  27. package/build/types-ts3.8/index.d.ts +3 -0
  28. package/build/types-ts3.8/resource.d.ts +26 -0
  29. package/build/types-ts3.8/sampler.d.ts +4 -1
  30. package/build/types-ts3.8/utils/buildContextWithSentryScopes.d.ts +12 -0
  31. package/build/types-ts3.8/utils/contextData.d.ts +7 -0
  32. package/package.json +2 -4
@@ -1 +1 @@
1
- {"type":"module","version":"10.47.0","sideEffects":false}
1
+ {"type":"module","version":"10.49.0","sideEffects":false}
@@ -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"}
@@ -5,6 +5,18 @@ export declare const SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING = "sentry.sampled_
5
5
  export declare const SENTRY_TRACE_STATE_URL = "sentry.url";
6
6
  export declare const SENTRY_TRACE_STATE_SAMPLE_RAND = "sentry.sample_rand";
7
7
  export declare const SENTRY_TRACE_STATE_SAMPLE_RATE = "sentry.sample_rate";
8
+ /**
9
+ * A flag marking a context as ignored because the span associated with the context
10
+ * is ignored (`ignoreSpans` filter).
11
+ */
12
+ export declare const SENTRY_TRACE_STATE_CHILD_IGNORED = "sentry.ignored";
13
+ /**
14
+ * A flag marking a segment span as ignored because it matched the `ignoreSpans` filter.
15
+ * Unlike `SENTRY_TRACE_STATE_CHILD_IGNORED` (used for child spans), this flag is NOT consumed
16
+ * by the context manager for re-parenting. Instead, it propagates to child spans so they
17
+ * can record the correct client report outcome (`ignored` instead of `sample_rate`).
18
+ */
19
+ export declare const SENTRY_TRACE_STATE_SEGMENT_IGNORED = "sentry.segment_ignored";
8
20
  export declare const SENTRY_SCOPES_CONTEXT_KEY: symbol;
9
21
  export declare const SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY: symbol;
10
22
  export declare const SENTRY_FORK_SET_SCOPE_CONTEXT_KEY: symbol;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,eAAO,MAAM,sBAAsB,eAAe,CAAC;AACnD,eAAO,MAAM,wCAAwC,iCAAiC,CAAC;AACvF,eAAO,MAAM,sBAAsB,eAAe,CAAC;AACnD,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AACnE,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AAEnE,eAAO,MAAM,yBAAyB,QAAoC,CAAC;AAE3E,eAAO,MAAM,uCAAuC,QAAkD,CAAC;AAEvG,eAAO,MAAM,iCAAiC,QAA4C,CAAC;AAE3F,eAAO,MAAM,2CAA2C,QAAsD,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,eAAO,MAAM,sBAAsB,eAAe,CAAC;AACnD,eAAO,MAAM,wCAAwC,iCAAiC,CAAC;AACvF,eAAO,MAAM,sBAAsB,eAAe,CAAC;AACnD,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AACnE,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AAEnE;;;GAGG;AACH,eAAO,MAAM,gCAAgC,mBAAmB,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,kCAAkC,2BAA2B,CAAC;AAE3E,eAAO,MAAM,yBAAyB,QAAoC,CAAC;AAE3E,eAAO,MAAM,uCAAuC,QAAkD,CAAC;AAEvG,eAAO,MAAM,iCAAiC,QAA4C,CAAC;AAE3F,eAAO,MAAM,2CAA2C,QAAsD,CAAC"}
@@ -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;AAYlE,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;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,sBAAsB,SAAS,cAAc,EACnF,mBAAmB,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,sBAAsB,GACtE,8BAA8B,CAAC,sBAAsB,CAAC,CAgExD"}
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"}
@@ -14,10 +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';
24
+ export { withStreamedSpan } from '@sentry/core';
22
25
  export { getClient } from '@sentry/core';
23
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","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,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { Attributes, AttributeValue } from '@opentelemetry/api';
2
+ type RawResourceAttribute = [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"}
@@ -8,6 +8,7 @@ import type { Client, SpanAttributes } from '@sentry/core';
8
8
  */
9
9
  export declare class SentrySampler implements Sampler {
10
10
  private _client;
11
+ private _isSpanStreaming;
11
12
  constructor(client: Client);
12
13
  /** @inheritDoc */
13
14
  shouldSample(context: Context, traceId: string, spanName: string, spanKind: SpanKind, spanAttributes: SpanAttributes, _links: unknown): SamplingResult;
@@ -19,11 +20,13 @@ export declare class SentrySampler implements Sampler {
19
20
  * If you pass `decision: undefined`, it will be treated as `NOT_RECORDING`, but in contrast to passing `NOT_RECORDING`
20
21
  * it will not propagate this decision to downstream Sentry SDKs.
21
22
  */
22
- export declare function wrapSamplingDecision({ decision, context, spanAttributes, sampleRand, downstreamTraceSampleRate, }: {
23
+ export declare function wrapSamplingDecision({ decision, context, spanAttributes, sampleRand, downstreamTraceSampleRate, ignoredChildSpan, ignoredSegmentSpan, }: {
23
24
  decision: SamplingDecision | undefined;
24
25
  context: Context;
25
26
  spanAttributes: SpanAttributes;
26
27
  sampleRand?: number;
27
28
  downstreamTraceSampleRate?: number;
29
+ ignoredChildSpan?: boolean;
30
+ ignoredSegmentSpan?: boolean;
28
31
  }): SamplingResult;
29
32
  //# sourceMappingURL=sampler.d.ts.map
@@ -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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AIxC;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC;;OAEG;IACI,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI;IAIxD,kBAAkB;IACX,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,YAAY,GAAG,IAAI;CAK9C"}
1
+ {"version":3,"file":"spanProcessor.d.ts","sourceRoot":"","sources":["../../src/spanProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,IAAI,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAejH;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,sBAAsB;IAChE,OAAO,CAAC,SAAS,CAAqB;gBAEnB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAKjD;;OAEG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxC;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC;;OAEG;IACI,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI;IAoCxD,kBAAkB;IACX,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,YAAY,GAAG,IAAI;CAY9C"}
@@ -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;AAI9C;;;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;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAEtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAErE"}
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
@@ -5,6 +5,18 @@ export declare const SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING = "sentry.sampled_
5
5
  export declare const SENTRY_TRACE_STATE_URL = "sentry.url";
6
6
  export declare const SENTRY_TRACE_STATE_SAMPLE_RAND = "sentry.sample_rand";
7
7
  export declare const SENTRY_TRACE_STATE_SAMPLE_RATE = "sentry.sample_rate";
8
+ /**
9
+ * A flag marking a context as ignored because the span associated with the context
10
+ * is ignored (`ignoreSpans` filter).
11
+ */
12
+ export declare const SENTRY_TRACE_STATE_CHILD_IGNORED = "sentry.ignored";
13
+ /**
14
+ * A flag marking a segment span as ignored because it matched the `ignoreSpans` filter.
15
+ * Unlike `SENTRY_TRACE_STATE_CHILD_IGNORED` (used for child spans), this flag is NOT consumed
16
+ * by the context manager for re-parenting. Instead, it propagates to child spans so they
17
+ * can record the correct client report outcome (`ignored` instead of `sample_rate`).
18
+ */
19
+ export declare const SENTRY_TRACE_STATE_SEGMENT_IGNORED = "sentry.segment_ignored";
8
20
  export declare const SENTRY_SCOPES_CONTEXT_KEY: symbol;
9
21
  export declare const SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY: symbol;
10
22
  export declare const SENTRY_FORK_SET_SCOPE_CONTEXT_KEY: symbol;
@@ -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,10 +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';
24
+ export { withStreamedSpan } from '@sentry/core';
22
25
  export { getClient } from '@sentry/core';
23
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
@@ -8,6 +8,7 @@ import { Client, SpanAttributes } from '@sentry/core';
8
8
  */
9
9
  export declare class SentrySampler implements Sampler {
10
10
  private _client;
11
+ private _isSpanStreaming;
11
12
  constructor(client: Client);
12
13
  /** @inheritDoc */
13
14
  shouldSample(context: Context, traceId: string, spanName: string, spanKind: SpanKind, spanAttributes: SpanAttributes, _links: unknown): SamplingResult;
@@ -19,11 +20,13 @@ export declare class SentrySampler implements Sampler {
19
20
  * If you pass `decision: undefined`, it will be treated as `NOT_RECORDING`, but in contrast to passing `NOT_RECORDING`
20
21
  * it will not propagate this decision to downstream Sentry SDKs.
21
22
  */
22
- export declare function wrapSamplingDecision({ decision, context, spanAttributes, sampleRand, downstreamTraceSampleRate, }: {
23
+ export declare function wrapSamplingDecision({ decision, context, spanAttributes, sampleRand, downstreamTraceSampleRate, ignoredChildSpan, ignoredSegmentSpan, }: {
23
24
  decision: SamplingDecision | undefined;
24
25
  context: Context;
25
26
  spanAttributes: SpanAttributes;
26
27
  sampleRand?: number;
27
28
  downstreamTraceSampleRate?: number;
29
+ ignoredChildSpan?: boolean;
30
+ ignoredSegmentSpan?: boolean;
28
31
  }): SamplingResult;
29
32
  //# sourceMappingURL=sampler.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.47.0",
3
+ "version": "10.49.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",
@@ -39,18 +39,16 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@sentry/core": "10.47.0"
42
+ "@sentry/core": "10.49.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@opentelemetry/api": "^1.9.0",
46
- "@opentelemetry/context-async-hooks": "^1.30.1 || ^2.1.0",
47
46
  "@opentelemetry/core": "^1.30.1 || ^2.1.0",
48
47
  "@opentelemetry/sdk-trace-base": "^1.30.1 || ^2.1.0",
49
48
  "@opentelemetry/semantic-conventions": "^1.39.0"
50
49
  },
51
50
  "devDependencies": {
52
51
  "@opentelemetry/api": "^1.9.1",
53
- "@opentelemetry/context-async-hooks": "^2.6.1",
54
52
  "@opentelemetry/core": "^2.6.1",
55
53
  "@opentelemetry/sdk-trace-base": "^2.6.1",
56
54
  "@opentelemetry/semantic-conventions": "^1.40.0"