@sentry/opentelemetry 10.63.0 → 10.64.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 (46) hide show
  1. package/README.md +29 -0
  2. package/build/cjs/{asyncContextStrategy-CvLbRw2N.js → asyncContextStrategy-xEzxBKVX.js} +214 -28
  3. package/build/cjs/asyncContextStrategy-xEzxBKVX.js.map +1 -0
  4. package/build/cjs/index.browser.js +5 -1
  5. package/build/cjs/index.browser.js.map +1 -1
  6. package/build/cjs/index.js +5 -1
  7. package/build/cjs/index.js.map +1 -1
  8. package/build/esm/{asyncContextStrategy-DfM95hx5.js → asyncContextStrategy-CIqtsDXI.js} +213 -30
  9. package/build/esm/asyncContextStrategy-CIqtsDXI.js.map +1 -0
  10. package/build/esm/index.browser.js +1 -1
  11. package/build/esm/index.js +3 -3
  12. package/build/esm/package.json +1 -1
  13. package/build/types/applyOtelSpanData.d.ts +18 -0
  14. package/build/types/applyOtelSpanData.d.ts.map +1 -0
  15. package/build/types/custom/client.d.ts.map +1 -1
  16. package/build/types/exports.d.ts +5 -1
  17. package/build/types/exports.d.ts.map +1 -1
  18. package/build/types/spanProcessor.d.ts.map +1 -1
  19. package/build/types/tracer.d.ts +13 -0
  20. package/build/types/tracer.d.ts.map +1 -0
  21. package/build/types/tracerProvider.d.ts +23 -0
  22. package/build/types/tracerProvider.d.ts.map +1 -0
  23. package/build/types/types.d.ts +6 -2
  24. package/build/types/types.d.ts.map +1 -1
  25. package/build/types/utils/backfillStreamedSpanData.d.ts +16 -0
  26. package/build/types/utils/backfillStreamedSpanData.d.ts.map +1 -0
  27. package/build/types/utils/enhanceDscWithOpenTelemetryRootSpanName.d.ts.map +1 -1
  28. package/build/types/utils/getSamplingDecision.d.ts +17 -0
  29. package/build/types/utils/getSamplingDecision.d.ts.map +1 -1
  30. package/build/types/utils/mapStatus.d.ts +3 -1
  31. package/build/types/utils/mapStatus.d.ts.map +1 -1
  32. package/build/types/utils/parseSpanDescription.d.ts.map +1 -1
  33. package/build/types/utils/setupCheck.d.ts +1 -1
  34. package/build/types/utils/setupCheck.d.ts.map +1 -1
  35. package/build/types-ts3.8/applyOtelSpanData.d.ts +18 -0
  36. package/build/types-ts3.8/exports.d.ts +5 -1
  37. package/build/types-ts3.8/tracer.d.ts +13 -0
  38. package/build/types-ts3.8/tracerProvider.d.ts +23 -0
  39. package/build/types-ts3.8/types.d.ts +6 -2
  40. package/build/types-ts3.8/utils/backfillStreamedSpanData.d.ts +16 -0
  41. package/build/types-ts3.8/utils/getSamplingDecision.d.ts +17 -0
  42. package/build/types-ts3.8/utils/mapStatus.d.ts +3 -1
  43. package/build/types-ts3.8/utils/setupCheck.d.ts +1 -1
  44. package/package.json +5 -5
  45. package/build/cjs/asyncContextStrategy-CvLbRw2N.js.map +0 -1
  46. package/build/esm/asyncContextStrategy-DfM95hx5.js.map +0 -1
@@ -0,0 +1,13 @@
1
+ import type { Context, Span as OpenTelemetrySpan, SpanOptions, Tracer } from '@opentelemetry/api';
2
+ export declare class SentryTracer implements Tracer {
3
+ /** @inheritdoc */
4
+ startSpan(name: string, options?: SpanOptions, ctx?: Context): OpenTelemetrySpan;
5
+ /** @inheritdoc */
6
+ startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, fn: F): ReturnType<F>;
7
+ startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, options: SpanOptions, fn: F): ReturnType<F>;
8
+ startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, options: SpanOptions, ctx: Context, fn: F): ReturnType<F>;
9
+ private _startSentrySpan;
10
+ private _startRootSpanWithRemoteParent;
11
+ private _createNonRecordingSpan;
12
+ }
13
+ //# sourceMappingURL=tracer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/tracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,IAAI,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AA0BlG,qBAAa,YAAa,YAAW,MAAM;IACzC,kBAAkB;IACX,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,iBAAiB;IAuB3F,kBAAkB;IACX,eAAe,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IACnG,eAAe,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,EACnE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,EACpB,EAAE,EAAE,CAAC,GACJ,UAAU,CAAC,CAAC,CAAC;IACT,eAAe,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,EACnE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,EACpB,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,CAAC,GACJ,UAAU,CAAC,CAAC,CAAC;IAwChB,OAAO,CAAC,gBAAgB;IAoCxB,OAAO,CAAC,8BAA8B;IA4BtC,OAAO,CAAC,uBAAuB;CAYhC"}
@@ -0,0 +1,23 @@
1
+ import type { Tracer, TracerOptions, TracerProvider } from '@opentelemetry/api';
2
+ import type { SpanAttributes } from '@sentry/core';
3
+ /**
4
+ * A minimal OpenTelemetry TracerProvider which creates native Sentry spans.
5
+ */
6
+ export declare class SentryTracerProvider implements TracerProvider {
7
+ readonly resource?: {
8
+ attributes: SpanAttributes;
9
+ };
10
+ private readonly _tracers;
11
+ constructor(options?: {
12
+ resource?: {
13
+ attributes: SpanAttributes;
14
+ };
15
+ });
16
+ /** @inheritdoc */
17
+ getTracer(name: string, version?: string, options?: TracerOptions): Tracer;
18
+ /** Compatibility with SDK tracer providers. */
19
+ forceFlush(): Promise<void>;
20
+ /** Compatibility with SDK tracer providers. */
21
+ shutdown(): Promise<void>;
22
+ }
23
+ //# sourceMappingURL=tracerProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracerProvider.d.ts","sourceRoot":"","sources":["../../src/tracerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD;;GAEG;AACH,qBAAa,oBAAqB,YAAW,cAAc;IACzD,SAAgB,QAAQ,CAAC,EAAE;QAAE,UAAU,EAAE,cAAc,CAAA;KAAE,CAAC;IAE1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;gBAEzC,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE;YAAE,UAAU,EAAE,cAAc,CAAA;SAAE,CAAA;KAAO;IAI9E,kBAAkB;IACX,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM;IAYjF,+CAA+C;IACxC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC,+CAA+C;IACxC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGjC"}
@@ -1,9 +1,13 @@
1
- import type { Span as WriteableSpan, SpanKind, Tracer } from '@opentelemetry/api';
1
+ import type { Span as WriteableSpan, SpanKind, Tracer, TracerProvider } from '@opentelemetry/api';
2
2
  import type { BasicTracerProvider, ReadableSpan } from '@opentelemetry/sdk-trace-base';
3
3
  import type { Scope, Span, StartSpanOptions } from '@sentry/core';
4
+ export interface OpenTelemetryTracerProvider extends TracerProvider {
5
+ forceFlush(): Promise<void>;
6
+ shutdown(): Promise<void>;
7
+ }
4
8
  export interface OpenTelemetryClient {
5
9
  tracer: Tracer;
6
- traceProvider: BasicTracerProvider | undefined;
10
+ traceProvider: BasicTracerProvider | OpenTelemetryTracerProvider | undefined;
7
11
  }
8
12
  export interface OpenTelemetrySpanContext extends StartSpanOptions {
9
13
  kind?: SpanKind;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,mBAAmB,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAEhE,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,IAAI,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,KAAK,CAAC;CACvB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClG,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,2BAA4B,SAAQ,cAAc;IACjE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,mBAAmB,GAAG,2BAA2B,GAAG,SAAS,CAAC;CAC9E;AAED,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAEhE,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,IAAI,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,KAAK,CAAC;CACvB"}
@@ -0,0 +1,16 @@
1
+ import type { StreamedSpanJSON } from '@sentry/core';
2
+ /**
3
+ * Backfill op, source, name and data on a streamed span JSON from OTel semantic conventions.
4
+ * Mirrors the inference the {@link SentrySpanExporter} applies to non-streamed spans via `getSpanData`.
5
+ * Explicitly set attributes are preserved via `safeSetSpanJSONAttributes`.
6
+ *
7
+ * Runs as a `preprocessSpan` subscriber (streamed-only) on both span pipelines: the OTel SDK
8
+ * `SentrySpanProcessor` and the `SentryTracerProvider`. On the latter, `applyOtelSpanData` has already
9
+ * inferred most data on the native span; this fills the remaining gap (per-span `sentry.source` on
10
+ * child spans, which `applyOtelSpanData` only sets on segment roots). `inferSpanData` is deterministic
11
+ * on the same attributes, so re-running it here is a no-op for already-inferred fields.
12
+ */
13
+ export declare function backfillStreamedSpanDataFromOtel(spanJSON: StreamedSpanJSON, hint?: {
14
+ spanKind?: number;
15
+ }): void;
16
+ //# sourceMappingURL=backfillStreamedSpanData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backfillStreamedSpanData.d.ts","sourceRoot":"","sources":["../../../src/utils/backfillStreamedSpanData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUrE;;;;;;;;;;GAUG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAmB/G"}
@@ -1 +1 @@
1
- {"version":3,"file":"enhanceDscWithOpenTelemetryRootSpanName.d.ts","sourceRoot":"","sources":["../../../src/utils/enhanceDscWithOpenTelemetryRootSpanName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAM3C;;;GAGG;AACH,wBAAgB,uCAAuC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA6B5E"}
1
+ {"version":3,"file":"enhanceDscWithOpenTelemetryRootSpanName.d.ts","sourceRoot":"","sources":["../../../src/utils/enhanceDscWithOpenTelemetryRootSpanName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C;;;GAGG;AACH,wBAAgB,uCAAuC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAiC5E"}
@@ -1,4 +1,5 @@
1
1
  import type { SpanContext } from '@opentelemetry/api';
2
+ import type { Client, Span } from '@sentry/core';
2
3
  /**
3
4
  * OpenTelemetry only knows about SAMPLED or NONE decision,
4
5
  * but for us it is important to differentiate between unset and unsampled.
@@ -7,4 +8,20 @@ import type { SpanContext } from '@opentelemetry/api';
7
8
  * but we additionally look at a special trace state to differentiate between them.
8
9
  */
9
10
  export declare function getSamplingDecision(spanContext: SpanContext): boolean | undefined;
11
+ /**
12
+ * Resolve a span's sampling decision for trace propagation, also handling native Sentry spans.
13
+ *
14
+ * Prefer the OpenTelemetry trace state via {@link getSamplingDecision}. Native Sentry spans (created
15
+ * by the `SentryTracerProvider`) don't carry that trace state, so when it's absent we fall back to the
16
+ * span's own decision via `spanIsSampled` — but only for an *explicit* decision. An explicit decision
17
+ * always originates at a real `SentrySpan` root (a negatively sampled root, or a child of one). A
18
+ * non-recording placeholder root (an orphan/suppressed span, or a TwP placeholder) and a remote span
19
+ * have a *deferred* decision that lives elsewhere (the scope, or the incoming trace state), so we
20
+ * return `undefined` and leave the decision deferred rather than wrongly asserting `-0`.
21
+ *
22
+ * TODO(v11): Once the OTel SDK provider is gone and every local span is a native Sentry span, the
23
+ * trace-state lookup only matters for remote (incoming) spans; the local path always reads the span's
24
+ * own decision, so the "native-vs-OTel-SDK span" framing can be dropped (local → span, remote → trace state).
25
+ */
26
+ export declare function getSampledForPropagation(span: Span, client: Client | undefined): boolean | undefined;
10
27
  //# sourceMappingURL=getSamplingDecision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSamplingDecision.d.ts","sourceRoot":"","sources":["../../../src/utils/getSamplingDecision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKtD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS,CA6BjF"}
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"}
@@ -1,7 +1,9 @@
1
- import type { SpanStatus } from '@sentry/core';
1
+ import type { SpanAttributes, SpanStatus } from '@sentry/core';
2
2
  import type { AbstractSpan } from '../types';
3
+ export declare const isStatusErrorMessageValid: (message: string) => boolean;
3
4
  /**
4
5
  * Get a Sentry span status from an otel span.
5
6
  */
6
7
  export declare function mapStatus(span: AbstractSpan): SpanStatus;
8
+ export declare function inferStatusFromAttributes(attributes: SpanAttributes): SpanStatus | undefined;
7
9
  //# sourceMappingURL=mapStatus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mapStatus.d.ts","sourceRoot":"","sources":["../../../src/utils/mapStatus.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA2B7C;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAsCxD"}
1
+ {"version":3,"file":"mapStatus.d.ts","sourceRoot":"","sources":["../../../src/utils/mapStatus.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAuB7C,eAAO,MAAM,yBAAyB,GAAI,SAAS,MAAM,KAAG,OAE3D,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAsCxD;AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,cAAc,GAAG,UAAU,GAAG,SAAS,CAwB5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"parseSpanDescription.d.ts","sourceRoot":"","sources":["../../../src/utils/parseSpanDescription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAe9C,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAWtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7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A;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,UAAU,EACtB,cAAc,GAAE,iBAA4B,GAC3C;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAYA"}
@@ -1,4 +1,4 @@
1
- type OpenTelemetryElement = 'SentrySpanProcessor' | 'SentryContextManager' | 'SentryPropagator' | 'SentrySampler';
1
+ type OpenTelemetryElement = 'SentrySpanProcessor' | 'SentryContextManager' | 'SentryPropagator' | 'SentrySampler' | 'SentryTracerProvider';
2
2
  /** Get all the OpenTelemetry elements that have been set up. */
3
3
  export declare function openTelemetrySetupCheck(): OpenTelemetryElement[];
4
4
  /** Mark an OpenTelemetry element as setup. */
@@ -1 +1 @@
1
- {"version":3,"file":"setupCheck.d.ts","sourceRoot":"","sources":["../../../src/utils/setupCheck.ts"],"names":[],"mappings":"AAAA,KAAK,oBAAoB,GAAG,qBAAqB,GAAG,sBAAsB,GAAG,kBAAkB,GAAG,eAAe,CAAC;AAIlH,gEAAgE;AAChE,wBAAgB,uBAAuB,IAAI,oBAAoB,EAAE,CAEhE;AAED,8CAA8C;AAC9C,wBAAgB,UAAU,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAE9D;AAED,+BAA+B;AAC/B,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD"}
1
+ {"version":3,"file":"setupCheck.d.ts","sourceRoot":"","sources":["../../../src/utils/setupCheck.ts"],"names":[],"mappings":"AAAA,KAAK,oBAAoB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,kBAAkB,GAClB,eAAe,GACf,sBAAsB,CAAC;AAI3B,gEAAgE;AAChE,wBAAgB,uBAAuB,IAAI,oBAAoB,EAAE,CAEhE;AAED,8CAA8C;AAC9C,wBAAgB,UAAU,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAE9D;AAED,+BAA+B;AAC/B,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD"}
@@ -0,0 +1,18 @@
1
+ import { SpanKind } from '@opentelemetry/api';
2
+ import { Span } from '@sentry/core';
3
+ /**
4
+ * Backfill a native Sentry span with the data the OpenTelemetry SDK pipeline would otherwise derive
5
+ * from OTel semantic attributes: `sentry.op`, `sentry.source`, the span name, `otel.kind`, and status.
6
+ *
7
+ * On the OTel SDK provider this happens in the `SentrySpanProcessor`/`SentrySpanExporter` while
8
+ * converting `ReadableSpan`s to Sentry payloads (via `parseSpanDescription` + `mapStatus`).
9
+ * `SentryTracerProvider` creates native Sentry spans directly and never goes through that pipeline,
10
+ * so the same inference has to run here instead — once at span start, and again at span end
11
+ * (`finalizeStatus`, once attributes like `http.route` and the status code are available).
12
+ */
13
+ export declare function applyOtelSpanData(span: Span, options?: {
14
+ finalizeStatus?: boolean;
15
+ }): void;
16
+ /** Stash the OTel span kind on a Sentry span so {@link applyOtelSpanData} can read it. */
17
+ export declare function applyOtelSpanKind(span: Span, kind: SpanKind | undefined): void;
18
+ //# sourceMappingURL=applyOtelSpanData.d.ts.map
@@ -16,7 +16,11 @@ export { wrapContextManagerClass } from './contextManager';
16
16
  export { SentryPropagator, shouldPropagateTraceForUrl } from './propagator';
17
17
  export { SentrySpanProcessor } from './spanProcessor';
18
18
  export { SentrySampler, wrapSamplingDecision } from './sampler';
19
- export { openTelemetrySetupCheck } from './utils/setupCheck';
19
+ export { applyOtelSpanData } from './applyOtelSpanData';
20
+ export { backfillStreamedSpanDataFromOtel } from './utils/backfillStreamedSpanData';
21
+ export { SentryTracerProvider } from './tracerProvider';
22
+ export { OpenTelemetryTracerProvider } from './types';
23
+ export { openTelemetrySetupCheck, setIsSetup } from './utils/setupCheck';
20
24
  export { getSentryResource } from './resource';
21
25
  export { withStreamedSpan } from '@sentry/core';
22
26
  export { getClient } from '@sentry/core';
@@ -0,0 +1,13 @@
1
+ import { Context, Span as OpenTelemetrySpan, SpanOptions, Tracer } from '@opentelemetry/api';
2
+ export declare class SentryTracer implements Tracer {
3
+ /** @inheritdoc */
4
+ startSpan(name: string, options?: SpanOptions, ctx?: Context): OpenTelemetrySpan;
5
+ /** @inheritdoc */
6
+ startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, fn: F): ReturnType<F>;
7
+ startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, options: SpanOptions, fn: F): ReturnType<F>;
8
+ startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, options: SpanOptions, ctx: Context, fn: F): ReturnType<F>;
9
+ private _startSentrySpan;
10
+ private _startRootSpanWithRemoteParent;
11
+ private _createNonRecordingSpan;
12
+ }
13
+ //# sourceMappingURL=tracer.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { Tracer, TracerOptions, TracerProvider } from '@opentelemetry/api';
2
+ import { SpanAttributes } from '@sentry/core';
3
+ /**
4
+ * A minimal OpenTelemetry TracerProvider which creates native Sentry spans.
5
+ */
6
+ export declare class SentryTracerProvider implements TracerProvider {
7
+ readonly resource?: {
8
+ attributes: SpanAttributes;
9
+ };
10
+ private readonly _tracers;
11
+ constructor(options?: {
12
+ resource?: {
13
+ attributes: SpanAttributes;
14
+ };
15
+ });
16
+ /** @inheritdoc */
17
+ getTracer(name: string, version?: string, options?: TracerOptions): Tracer;
18
+ /** Compatibility with SDK tracer providers. */
19
+ forceFlush(): Promise<void>;
20
+ /** Compatibility with SDK tracer providers. */
21
+ shutdown(): Promise<void>;
22
+ }
23
+ //# sourceMappingURL=tracerProvider.d.ts.map
@@ -1,9 +1,13 @@
1
- import { Span as WriteableSpan, SpanKind, Tracer } from '@opentelemetry/api';
1
+ import { Span as WriteableSpan, SpanKind, Tracer, TracerProvider } from '@opentelemetry/api';
2
2
  import { BasicTracerProvider, ReadableSpan } from '@opentelemetry/sdk-trace-base';
3
3
  import { Scope, Span, StartSpanOptions } from '@sentry/core';
4
+ export interface OpenTelemetryTracerProvider extends TracerProvider {
5
+ forceFlush(): Promise<void>;
6
+ shutdown(): Promise<void>;
7
+ }
4
8
  export interface OpenTelemetryClient {
5
9
  tracer: Tracer;
6
- traceProvider: BasicTracerProvider | undefined;
10
+ traceProvider: BasicTracerProvider | OpenTelemetryTracerProvider | undefined;
7
11
  }
8
12
  export interface OpenTelemetrySpanContext extends StartSpanOptions {
9
13
  kind?: SpanKind;
@@ -0,0 +1,16 @@
1
+ import { StreamedSpanJSON } from '@sentry/core';
2
+ /**
3
+ * Backfill op, source, name and data on a streamed span JSON from OTel semantic conventions.
4
+ * Mirrors the inference the {@link SentrySpanExporter} applies to non-streamed spans via `getSpanData`.
5
+ * Explicitly set attributes are preserved via `safeSetSpanJSONAttributes`.
6
+ *
7
+ * Runs as a `preprocessSpan` subscriber (streamed-only) on both span pipelines: the OTel SDK
8
+ * `SentrySpanProcessor` and the `SentryTracerProvider`. On the latter, `applyOtelSpanData` has already
9
+ * inferred most data on the native span; this fills the remaining gap (per-span `sentry.source` on
10
+ * child spans, which `applyOtelSpanData` only sets on segment roots). `inferSpanData` is deterministic
11
+ * on the same attributes, so re-running it here is a no-op for already-inferred fields.
12
+ */
13
+ export declare function backfillStreamedSpanDataFromOtel(spanJSON: StreamedSpanJSON, hint?: {
14
+ spanKind?: number;
15
+ }): void;
16
+ //# sourceMappingURL=backfillStreamedSpanData.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import { SpanContext } from '@opentelemetry/api';
2
+ import { Client, Span } from '@sentry/core';
2
3
  /**
3
4
  * OpenTelemetry only knows about SAMPLED or NONE decision,
4
5
  * but for us it is important to differentiate between unset and unsampled.
@@ -7,4 +8,20 @@ import { SpanContext } from '@opentelemetry/api';
7
8
  * but we additionally look at a special trace state to differentiate between them.
8
9
  */
9
10
  export declare function getSamplingDecision(spanContext: SpanContext): boolean | undefined;
11
+ /**
12
+ * Resolve a span's sampling decision for trace propagation, also handling native Sentry spans.
13
+ *
14
+ * Prefer the OpenTelemetry trace state via {@link getSamplingDecision}. Native Sentry spans (created
15
+ * by the `SentryTracerProvider`) don't carry that trace state, so when it's absent we fall back to the
16
+ * span's own decision via `spanIsSampled` — but only for an *explicit* decision. An explicit decision
17
+ * always originates at a real `SentrySpan` root (a negatively sampled root, or a child of one). A
18
+ * non-recording placeholder root (an orphan/suppressed span, or a TwP placeholder) and a remote span
19
+ * have a *deferred* decision that lives elsewhere (the scope, or the incoming trace state), so we
20
+ * return `undefined` and leave the decision deferred rather than wrongly asserting `-0`.
21
+ *
22
+ * TODO(v11): Once the OTel SDK provider is gone and every local span is a native Sentry span, the
23
+ * trace-state lookup only matters for remote (incoming) spans; the local path always reads the span's
24
+ * own decision, so the "native-vs-OTel-SDK span" framing can be dropped (local → span, remote → trace state).
25
+ */
26
+ export declare function getSampledForPropagation(span: Span, client: Client | undefined): boolean | undefined;
10
27
  //# sourceMappingURL=getSamplingDecision.d.ts.map
@@ -1,7 +1,9 @@
1
- import { SpanStatus } from '@sentry/core';
1
+ import { SpanAttributes, SpanStatus } from '@sentry/core';
2
2
  import { AbstractSpan } from '../types';
3
+ export declare const isStatusErrorMessageValid: (message: string) => boolean;
3
4
  /**
4
5
  * Get a Sentry span status from an otel span.
5
6
  */
6
7
  export declare function mapStatus(span: AbstractSpan): SpanStatus;
8
+ export declare function inferStatusFromAttributes(attributes: SpanAttributes): SpanStatus | undefined;
7
9
  //# sourceMappingURL=mapStatus.d.ts.map
@@ -1,4 +1,4 @@
1
- type OpenTelemetryElement = 'SentrySpanProcessor' | 'SentryContextManager' | 'SentryPropagator' | 'SentrySampler';
1
+ type OpenTelemetryElement = 'SentrySpanProcessor' | 'SentryContextManager' | 'SentryPropagator' | 'SentrySampler' | 'SentryTracerProvider';
2
2
  /** Get all the OpenTelemetry elements that have been set up. */
3
3
  export declare function openTelemetrySetupCheck(): OpenTelemetryElement[];
4
4
  /** Mark an OpenTelemetry element as setup. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/opentelemetry",
3
- "version": "10.63.0",
3
+ "version": "10.64.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",
@@ -55,8 +55,8 @@
55
55
  "access": "public"
56
56
  },
57
57
  "dependencies": {
58
- "@sentry/conventions": "^0.12.0",
59
- "@sentry/core": "10.63.0"
58
+ "@sentry/conventions": "^0.15.1",
59
+ "@sentry/core": "10.64.0"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@opentelemetry/api": "^1.9.0",
@@ -65,8 +65,8 @@
65
65
  },
66
66
  "devDependencies": {
67
67
  "@opentelemetry/api": "^1.9.1",
68
- "@opentelemetry/core": "^2.6.1",
69
- "@opentelemetry/sdk-trace-base": "^2.6.1"
68
+ "@opentelemetry/core": "^2.9.0",
69
+ "@opentelemetry/sdk-trace-base": "^2.9.0"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "run-p build:transpile build:types",