@sentry/opentelemetry 11.0.0-alpha.1 → 11.0.0-alpha.2
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/build/cjs/index.js +79 -213
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +81 -216
- package/build/esm/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/asyncContextStrategy.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/prepareSpanScope.d.ts +11 -0
- package/build/types/prepareSpanScope.d.ts.map +1 -0
- package/build/types/trace.d.ts +1 -33
- package/build/types/trace.d.ts.map +1 -1
- package/build/types/tracer.d.ts +6 -1
- package/build/types/tracer.d.ts.map +1 -1
- package/build/types/utils/getActiveSpan.d.ts +5 -1
- package/build/types/utils/getActiveSpan.d.ts.map +1 -1
- package/package.json +4 -3
- package/build/types/utils/reconcileDscSampled.d.ts +0 -14
- package/build/types/utils/reconcileDscSampled.d.ts.map +0 -1
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/constants.ts","../../src/utils/contextData.ts","../../src/utils/TraceState.ts","../../src/utils/makeTraceState.ts","../../src/propagator.ts","../../src/utils/suppressTracing.ts","../../src/utils/getSamplingDecision.ts","../../src/tracer.ts","../../src/tracerProvider.ts","../../src/utils/reconcileDscSampled.ts","../../src/trace.ts","../../src/utils/getActiveSpan.ts","../../src/utils/buildContextWithSentryScopes.ts","../../src/asyncLocalStorageContextManager.ts","../../src/asyncContextStrategy.ts"],"sourcesContent":["import { createContextKey } from '@opentelemetry/api';\n\nexport const SENTRY_TRACE_HEADER = 'sentry-trace';\nexport const SENTRY_BAGGAGE_HEADER = 'baggage';\n\nexport const SENTRY_TRACE_STATE_DSC = 'sentry.dsc';\nexport const SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING = 'sentry.sampled_not_recording';\n\nexport const SENTRY_SCOPES_CONTEXT_KEY = createContextKey('sentry_scopes');\n\nexport const SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY = createContextKey('sentry_fork_isolation_scope');\n\nexport const SENTRY_FORK_SET_SCOPE_CONTEXT_KEY = createContextKey('sentry_fork_set_scope');\n\nexport const SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY = createContextKey('sentry_fork_set_isolation_scope');\n","import type { Context } from '@opentelemetry/api';\nimport type { Scope } from '@sentry/core';\nimport { derefWeakRef, makeWeakRef, type MaybeWeakRef } from '@sentry/core';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from '../constants';\nimport type { CurrentScopes } from '../types';\n\nconst SCOPE_CONTEXT_FIELD = 'context';\n\n/**\n * Try to get the current scopes from the given OTEL context.\n * This requires a Context Manager that was wrapped with getWrappedContextManager.\n */\nexport function getScopesFromContext(context: Context): CurrentScopes | undefined {\n return context.getValue(SENTRY_SCOPES_CONTEXT_KEY) as CurrentScopes | undefined;\n}\n\n/**\n * Set the current scopes on an OTEL context.\n * This will return a forked context with the Propagation Context set.\n */\nexport function setScopesOnContext(context: Context, scopes: CurrentScopes): Context {\n return context.setValue(SENTRY_SCOPES_CONTEXT_KEY, scopes);\n}\n\n/**\n * Set the context on the scope so we can later look it up.\n * We need this to get the context from the scope in the `trace` functions.\n *\n * We use WeakRef to avoid a circular reference between the scope and the context.\n * The context holds scopes (via SENTRY_SCOPES_CONTEXT_KEY), and if the scope held\n * a strong reference back to the context, neither could be garbage collected even\n * when the context is no longer reachable from application code (e.g., after a\n * request completes but pooled connections retain patched callbacks).\n */\nexport function setContextOnScope(scope: Scope, context: Context): void {\n scope.refs[SCOPE_CONTEXT_FIELD] = makeWeakRef(context);\n}\n\n/**\n * Get the context related to a scope.\n * Returns undefined if the context has been garbage collected (when WeakRef is used).\n */\nexport function getContextFromScope(scope: Scope): Context | undefined {\n return derefWeakRef(scope.refs[SCOPE_CONTEXT_FIELD] as MaybeWeakRef<Context> | undefined);\n}\n","/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Minimal vendored implementation of `TraceState` from `@opentelemetry/core`\n * to avoid pulling in that dependency for a single class.\n * - Drops raw-string parsing and key/value validation, neither of which are\n * used by the SDK — the W3C `tracestate` header is parsed by OTel's own\n * propagators (which use their own `TraceState`), and every key we `set`\n * is a known constant.\n */\nimport type { TraceState as TraceStateInterface } from '@opentelemetry/api';\n\n/**\n * Minimal implementation of the W3C `tracestate` field as a `@opentelemetry/api`\n * `TraceState`. New entries are inserted at the front of the list, and updating\n * an existing key moves it to the front.\n *\n * See https://www.w3.org/TR/trace-context/#tracestate-field for the field spec.\n */\nexport class TraceState implements TraceStateInterface {\n private _internalState: Map<string, string> = new Map();\n\n /** @inheritDoc */\n public set(key: string, value: string): TraceState {\n const next = this._clone();\n if (next._internalState.has(key)) {\n next._internalState.delete(key);\n }\n next._internalState.set(key, value);\n return next;\n }\n\n /** @inheritDoc */\n public unset(key: string): TraceState {\n const next = this._clone();\n next._internalState.delete(key);\n return next;\n }\n\n /** @inheritDoc */\n public get(key: string): string | undefined {\n return this._internalState.get(key);\n }\n\n /** @inheritDoc */\n public serialize(): string {\n return Array.from(this._internalState.keys())\n .reverse()\n .map(key => `${key}=${this._internalState.get(key)}`)\n .join(',');\n }\n\n private _clone(): TraceState {\n const next = new TraceState();\n next._internalState = new Map(this._internalState);\n return next;\n }\n}\n","import type { DynamicSamplingContext } from '@sentry/core';\nimport { dynamicSamplingContextToSentryBaggageHeader } from '@sentry/core';\nimport { SENTRY_TRACE_STATE_DSC, SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING } from '../constants';\nimport { TraceState } from './TraceState';\n\n/**\n * Generate a TraceState for the given data.\n */\nexport function makeTraceState({\n dsc,\n sampled,\n}: {\n dsc?: Partial<DynamicSamplingContext>;\n sampled?: boolean;\n}): TraceState {\n // We store the DSC as OTEL trace state on the span context\n const dscString = dsc ? dynamicSamplingContextToSentryBaggageHeader(dsc) : undefined;\n\n const traceStateBase = new TraceState();\n\n const traceStateWithDsc = dscString ? traceStateBase.set(SENTRY_TRACE_STATE_DSC, dscString) : traceStateBase;\n\n // We also specifically want to store if this is sampled to be not recording,\n // or unsampled (=could be either sampled or not)\n return sampled === false ? traceStateWithDsc.set(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING, '1') : traceStateWithDsc;\n}\n","import type { Context, SpanContext, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';\nimport { context, trace, TraceFlags } from '@opentelemetry/api';\nimport type { continueTrace, DynamicSamplingContext } from '@sentry/core';\nimport {\n _INTERNAL_safeMathRandom,\n baggageHeaderToDynamicSamplingContext,\n consoleSandbox,\n generateTraceId,\n getClient,\n getCurrentScope,\n getIsolationScope,\n getTraceData,\n isTracingSuppressed,\n propagationContextFromHeaders,\n shouldContinueTrace,\n} from '@sentry/core';\nimport { getScopesFromContext, setScopesOnContext } from './utils/contextData';\nimport { makeTraceState } from './utils/makeTraceState';\n\nconst SENTRY_TRACE_HEADER = 'sentry-trace';\nconst SENTRY_BAGGAGE_HEADER = 'baggage';\nconst W3C_TRACEPARENT_HEADER = 'traceparent';\n\n/**\n * A minimal OpenTelemetry `TextMapPropagator` that injects and extracts Sentry trace data.\n *\n * This propagator only supports injecting/extracting from current context, for simplicity sake.\n * It will bail and do nothing if using a different context.\n */\nexport class SentryPropagator implements TextMapPropagator {\n /** @inheritDoc */\n public inject(ctx: Context, carrier: unknown, setter: TextMapSetter): void {\n if (ctx !== context.active()) {\n consoleSandbox(() => {\n // oxlint-disable-next-line no-console\n console.warn(\n 'SentryPropagator: Injecting trace data of a different context than the active one is not supported. Skipping injection.',\n );\n });\n return;\n }\n\n if (isTracingSuppressed()) {\n return;\n }\n\n const { propagateTraceparent } = getClient()?.getOptions() ?? {};\n\n // Pick trace data from the current scope\n const { 'sentry-trace': sentryTrace, baggage, traceparent } = getTraceData({ propagateTraceparent });\n\n if (sentryTrace) {\n setter.set(carrier, SENTRY_TRACE_HEADER, sentryTrace);\n }\n if (baggage) {\n setter.set(carrier, SENTRY_BAGGAGE_HEADER, baggage);\n }\n if (traceparent) {\n setter.set(carrier, W3C_TRACEPARENT_HEADER, traceparent);\n }\n }\n\n /** @inheritDoc */\n public extract(ctx: Context, carrier: unknown, getter: TextMapGetter): Context {\n const maybeSentryTraceHeader: string | string[] | undefined = getter.get(carrier, SENTRY_TRACE_HEADER);\n const baggage = getter.get(carrier, SENTRY_BAGGAGE_HEADER);\n\n const sentryTrace = Array.isArray(maybeSentryTraceHeader) ? maybeSentryTraceHeader[0] : maybeSentryTraceHeader;\n\n // Add remote parent span context. If there is no incoming trace, this returns the context as-is.\n return getContextWithRemoteActiveSpanAndScopes(ctx, { sentryTrace, baggage });\n }\n\n /** @inheritDoc */\n public fields(): string[] {\n return [SENTRY_TRACE_HEADER, SENTRY_BAGGAGE_HEADER, W3C_TRACEPARENT_HEADER];\n }\n}\n\nfunction getContextWithRemoteActiveSpan(\n ctx: Context,\n { sentryTrace, baggage }: Parameters<typeof continueTrace>[0],\n): Context {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n\n const { traceId, parentSpanId, sampled, dsc } = propagationContext;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n\n // We only want to set the virtual span if we are continuing a concrete trace\n // Otherwise, we ignore the incoming trace here, e.g. if we have no trace headers\n if (!parentSpanId || (client && !shouldContinueTrace(client, incomingDsc?.org_id))) {\n return ctx;\n }\n\n const spanContext = generateRemoteSpanContext({\n traceId,\n spanId: parentSpanId,\n sampled,\n dsc,\n });\n\n return trace.setSpanContext(ctx, spanContext);\n}\n\n/**\n * Build a context that continues an incoming trace as a remote active span, with scopes ensured.\n * Returns the context so it can be used to implement an OpenTelemetry propagator's `extract`.\n */\nfunction getContextWithRemoteActiveSpanAndScopes(ctx: Context, options: Parameters<typeof continueTrace>[0]): Context {\n const ctxWithRemoteSpan = getContextWithRemoteActiveSpan(ctx, options);\n // If a remote active span was set, we are continuing an incoming trace, so the trace id is fixed.\n // Otherwise there was no (valid) incoming trace and we are the head of a new trace.\n const isContinuingTrace = trace.getSpanContext(ctxWithRemoteSpan) !== undefined;\n return ensureScopesOnContext(ctxWithRemoteSpan, isContinuingTrace);\n}\n\nfunction ensureScopesOnContext(ctx: Context, isContinuingTrace: boolean): Context {\n // If there are no scopes yet on the context, ensure we have them\n const scopes = getScopesFromContext(ctx);\n\n // If we have no scope here, this is most likely either the root context or a context manually derived from it\n // In this case, we want to fork the current scope, to ensure we do not pollute the root scope\n const scope = scopes ? scopes.scope : getCurrentScope().clone();\n\n // When we forked a fresh scope and are not continuing an incoming trace, we give it its own trace.\n // Without this, concurrent header-less requests (e.g. edge middleware, whose root span is created by\n // upstream OTEL instrumentation rather than through `continueTrace`) would all inherit the forked\n // scope's trace id and collapse into a single trace. Mirrors `continueTrace` in the core HTTP server.\n if (!scopes && !isContinuingTrace) {\n const propagationContext = scope.getPropagationContext();\n scope.setPropagationContext({\n ...propagationContext,\n traceId: generateTraceId(),\n sampleRand: _INTERNAL_safeMathRandom(),\n });\n }\n\n const newScopes = {\n scope,\n isolationScope: scopes ? scopes.isolationScope : getIsolationScope(),\n };\n\n return setScopesOnContext(ctx, newScopes);\n}\n\nfunction generateRemoteSpanContext({\n spanId,\n traceId,\n sampled,\n dsc,\n}: {\n spanId: string;\n traceId: string;\n sampled: boolean | undefined;\n dsc?: Partial<DynamicSamplingContext>;\n}): SpanContext {\n // We store the DSC as OTEL trace state on the span context\n const traceState = makeTraceState({\n dsc,\n sampled,\n });\n\n const spanContext: SpanContext = {\n traceId,\n spanId,\n isRemote: true,\n traceFlags: sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,\n traceState,\n };\n\n return spanContext;\n}\n","/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Minimal vendored implementation of the tracing-suppression helpers from\n * `@opentelemetry/core` to avoid pulling in that dependency.\n * - The context key string must stay byte-identical to OTel's, since other\n * OpenTelemetry instrumentation (e.g. `@opentelemetry/instrumentation-http`)\n * writes to the same key and our tracer reads it back to suppress spans.\n * - `unsuppressTracing` is dropped, as the SDK never removes the flag.\n */\nimport type { Context } from '@opentelemetry/api';\nimport { createContextKey } from '@opentelemetry/api';\n\nconst SUPPRESS_TRACING_KEY = createContextKey('OpenTelemetry SDK Context Key SUPPRESS_TRACING');\n\n/** Returns a new context with tracing suppressed, so no spans are created within it. */\nexport function suppressTracing(context: Context): Context {\n return context.setValue(SUPPRESS_TRACING_KEY, true);\n}\n\n/** Whether tracing is suppressed in the given context. */\nexport function isTracingSuppressed(context: Context): boolean {\n return context.getValue(SUPPRESS_TRACING_KEY) === true;\n}\n","import type { SpanContext } from '@opentelemetry/api';\nimport { TraceFlags } from '@opentelemetry/api';\nimport { baggageHeaderToDynamicSamplingContext } from '@sentry/core';\nimport { SENTRY_TRACE_STATE_DSC, SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING } from '../constants';\n\n/**\n * OpenTelemetry only knows about SAMPLED or NONE decision,\n * but for us it is important to differentiate between unset and unsampled.\n *\n * Both of these are identified as `traceFlags === TracegFlags.NONE`,\n * but we additionally look at a special trace state to differentiate between them.\n */\nexport function getSamplingDecision(spanContext: SpanContext): boolean | undefined {\n const { traceFlags, traceState } = spanContext;\n\n const sampledNotRecording = traceState ? traceState.get(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING) === '1' : false;\n\n // If trace flag is `SAMPLED`, we interpret this as sampled\n // If it is `NONE`, it could mean either it was sampled to be not recorder, or that it was not sampled at all\n // For us this is an important difference, sow e look at the SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING\n // to identify which it is\n if (traceFlags === TraceFlags.SAMPLED) {\n return true;\n }\n\n if (sampledNotRecording) {\n return false;\n }\n\n // Fall back to DSC as a last resort, that may also contain `sampled`...\n const dscString = traceState ? traceState.get(SENTRY_TRACE_STATE_DSC) : undefined;\n const dsc = dscString ? baggageHeaderToDynamicSamplingContext(dscString) : undefined;\n\n if (dsc?.sampled === 'true') {\n return true;\n }\n if (dsc?.sampled === 'false') {\n return false;\n }\n\n return undefined;\n}\n","import type { Context, Span as OpenTelemetrySpan, SpanOptions, Tracer } from '@opentelemetry/api';\nimport { context, isSpanContextValid, trace } from '@opentelemetry/api';\nimport { isTracingSuppressed } from './utils/suppressTracing';\nimport {\n _INTERNAL_safeMathRandom,\n _INTERNAL_setSpanForScope,\n _INTERNAL_startInactiveSpan,\n addChildSpanToSpan,\n getCapturedScopesOnSpan,\n getCurrentScope,\n getDynamicSamplingContextFromSpan,\n getIsolationScope,\n markSpanAsTracerProviderSpan,\n SentryNonRecordingSpan,\n setCapturedScopesOnSpan,\n spanIsIgnored,\n spanKindToName,\n startNewTrace,\n withScope,\n} from '@sentry/core';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport { SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, SENTRY_TRACE_STATE_DSC } from './constants';\nimport { getSamplingDecision } from './utils/getSamplingDecision';\nimport { SENTRY_KIND } from '@sentry/conventions/attributes';\n\nexport class SentryTracer implements Tracer {\n /** @inheritdoc */\n public startSpan(name: string, options: SpanOptions = {}, ctx?: Context): OpenTelemetrySpan {\n const parentContext = ctx || context.active();\n const parentSpanCandidate = options.root ? undefined : trace.getSpan(parentContext);\n // Ignore an invalid parent (e.g. a malformed incoming trace/span id) and start a fresh trace,\n // matching the OTel SDK sampler's `getValidSpan` behaviour.\n const parentSpan =\n parentSpanCandidate && isSpanContextValid(parentSpanCandidate.spanContext()) ? parentSpanCandidate : undefined;\n\n if (isTracingSuppressed(parentContext)) {\n return this._createNonRecordingSpan(parentSpan);\n }\n\n const span = this._startSentrySpan(name, options, parentSpan, ctx !== undefined);\n\n // Mark the span as provider-created so it becomes immutable after `end()` like an OTel SDK span\n // (see `SentrySpan.end()`). Spans created directly through the core API (e.g. the browser SDK)\n // are not marked and keep their mutable behavior.\n markSpanAsTracerProviderSpan(span);\n\n return span;\n }\n\n /** @inheritdoc */\n public startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, fn: F): ReturnType<F>;\n public startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(\n name: string,\n options: SpanOptions,\n fn: F,\n ): ReturnType<F>;\n public startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(\n name: string,\n options: SpanOptions,\n ctx: Context,\n fn: F,\n ): ReturnType<F>;\n public startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(\n name: string,\n optionsOrFn: SpanOptions | F,\n contextOrFn?: Context | F,\n fn?: F,\n ): ReturnType<F> {\n const options = typeof optionsOrFn === 'function' ? {} : optionsOrFn;\n const ctx = typeof contextOrFn === 'function' || contextOrFn === undefined ? context.active() : contextOrFn;\n const callback = (\n typeof optionsOrFn === 'function' ? optionsOrFn : typeof contextOrFn === 'function' ? contextOrFn : fn\n ) as F;\n\n const span = this.startSpan(name, options, ctx);\n\n // Run the span's callback under the isolation scope captured when the span was created, so scope state\n // used or set during the span (tags, breadcrumbs, captured errors) belongs to that span and stays\n // isolated from other concurrent work. Without this it can land on a different isolation scope. This\n // holds for ignored spans too, which run the callback without ever becoming the active span.\n const capturedIsolationScope = getCapturedScopesOnSpan(span).isolationScope;\n const withCapturedIsolationScope = (contextToFork: Context): Context =>\n capturedIsolationScope\n ? contextToFork.setValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, capturedIsolationScope)\n : contextToFork;\n\n // Mirror core's `startSpan`: an ignored (`ignoreSpans`) span that has a parent must not become the\n // active span. Otherwise its children would attach to it and, since it's non-recording, be dropped\n // along with it (cascading the drop down the whole subtree). Leaving the parent active lets the\n // children attach to it and get re-parented instead. An ignored root span has no parent and still\n // becomes active, so its subtree is dropped as intended.\n if (spanIsIgnored(span) && trace.getSpan(ctx)) {\n return context.with(withCapturedIsolationScope(ctx), () => callback(span)) as ReturnType<F>;\n }\n\n return context.with(withCapturedIsolationScope(trace.setSpan(ctx, span)), () => {\n _INTERNAL_setSpanForScope(getCurrentScope(), span);\n return callback(span) as ReturnType<F>;\n });\n }\n\n private _startSentrySpan(\n name: string,\n options: SpanOptions,\n parentSpan: OpenTelemetrySpan | undefined,\n hasExplicitContext: boolean,\n ): Span {\n const sentryOptions = {\n name,\n attributes: (options.attributes as SpanAttributes) || {},\n links: options.links,\n startTime: options.startTime,\n };\n\n // Convert otel kind to our sentry.kind attribtue\n if (options.kind) {\n sentryOptions.attributes[SENTRY_KIND] = spanKindToName(options.kind);\n }\n\n if (options.root) {\n return startNewTrace(() => _INTERNAL_startInactiveSpan({ ...sentryOptions, parentSpan: null }));\n }\n\n if (parentSpan?.spanContext().isRemote) {\n return this._startRootSpanWithRemoteParent(sentryOptions, parentSpan);\n }\n\n if (parentSpan) {\n return _INTERNAL_startInactiveSpan({ ...sentryOptions, parentSpan: parentSpan });\n }\n\n // No parent span and no remote parent: this is a fresh root span.\n return _INTERNAL_startInactiveSpan({\n ...sentryOptions,\n parentSpan: hasExplicitContext ? null : undefined,\n });\n }\n\n private _startRootSpanWithRemoteParent(\n options: Parameters<typeof _INTERNAL_startInactiveSpan>[0],\n parentSpan: OpenTelemetrySpan,\n ): Span {\n const { spanId, traceId, traceState } = parentSpan.spanContext();\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const sampleRand = typeof dsc.sample_rand === 'string' ? Number(dsc.sample_rand) : undefined;\n\n // Only freeze the DSC when the remote parent actually carried one (i.e. there was incoming\n // baggage). Otherwise leave it unset so it is derived dynamically from the span — picking up the\n // span's `transaction` name and the generated `sample_rand` — matching the OpenTelemetry SDK.\n const hasIncomingDsc = !!traceState?.get(SENTRY_TRACE_STATE_DSC);\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId,\n parentSpanId: spanId,\n sampled: getSamplingDecision(parentSpan.spanContext()),\n dsc: hasIncomingDsc ? dsc : undefined,\n sampleRand:\n typeof sampleRand === 'number' && !Number.isNaN(sampleRand) ? sampleRand : _INTERNAL_safeMathRandom(),\n });\n _INTERNAL_setSpanForScope(scope, undefined);\n\n return _INTERNAL_startInactiveSpan({ ...options, parentSpan: null });\n });\n }\n\n private _createNonRecordingSpan(parentSpan: OpenTelemetrySpan | undefined): OpenTelemetrySpan {\n // Without a parent, fall back to the current scope's propagation context trace id, so that\n // non-recording spans (TwP mode) stay on the trace set by `startNewTrace`/`continueTrace`\n // instead of minting a fresh random trace id. Mirrors core's `createChildOrRootSpan` TwP branch.\n const traceId = parentSpan?.spanContext().traceId ?? getCurrentScope().getPropagationContext().traceId;\n const span = new SentryNonRecordingSpan({ traceId });\n // Link to the parent (like core's `createChildOrRootSpan`) so `getRootSpan` and DSC\n // resolution reach the parent. Non-recording spans no longer carry a `parentSpanId`.\n if (parentSpan) {\n addChildSpanToSpan(parentSpan, span);\n }\n // Capture the scopes (mirroring `createChildOrRootSpan`) so `startActiveSpan` can\n // fork the isolation scope onto the OTel context for work inside a suppressed span.\n setCapturedScopesOnSpan(span, getCurrentScope(), getIsolationScope());\n return span;\n }\n}\n","import type { Tracer, TracerOptions, TracerProvider } from '@opentelemetry/api';\nimport { SentryTracer } from './tracer';\n\n/**\n * A minimal OpenTelemetry TracerProvider which creates native Sentry spans.\n */\nexport class SentryTracerProvider implements TracerProvider {\n private readonly _tracers = new Map<string, SentryTracer>();\n\n /** @inheritdoc */\n public getTracer(name: string, version?: string, options?: TracerOptions): Tracer {\n const key = JSON.stringify([name, version, options]);\n const cachedTracer = this._tracers.get(key);\n if (cachedTracer) {\n return cachedTracer;\n }\n\n const tracer = new SentryTracer();\n this._tracers.set(key, tracer);\n return tracer;\n }\n\n /** Compatibility with SDK tracer providers. */\n public forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n /** Compatibility with SDK tracer providers. */\n public shutdown(): Promise<void> {\n return Promise.resolve();\n }\n}\n","import type { DynamicSamplingContext } from '@sentry/core';\n\n/**\n * Reconcile a freshly-derived DSC's `sampled` flag with the OTel sampling decision.\n *\n * Only applies to a DSC that core generated from the span's (binary) trace flags — never to a frozen\n * incoming DSC from the trace state, which the caller leaves untouched per the propagation spec.\n * Trace flags cannot tell a *deferred* decision (an incoming remote span whose decision lives in the\n * trace state) apart from a definitive *unsampled* one — both read as `traceFlags: NONE`.\n * `getSamplingDecision` resolves this via the OTel trace state, so we let it win here: drop `sampled`\n * when the decision is deferred (`undefined`), and — matching the OTel SDK, whose unsampled spans are\n * nameless non-recording spans — drop the transaction name when the trace is definitively unsampled.\n */\nexport function reconcileDscSampled(\n dsc: Partial<DynamicSamplingContext>,\n sampled: boolean | undefined,\n): Partial<DynamicSamplingContext> {\n const reconciled = { ...dsc };\n\n if (sampled === undefined) {\n delete reconciled.sampled;\n } else {\n reconciled.sampled = String(sampled);\n if (sampled === false) {\n delete reconciled.transaction;\n }\n }\n\n return reconciled;\n}\n","import type { Context, Span, SpanContext, SpanOptions, TimeInput, Tracer } from '@opentelemetry/api';\nimport { context, SpanStatusCode, trace, TraceFlags } from '@opentelemetry/api';\nimport { isTracingSuppressed, suppressTracing } from './utils/suppressTracing';\nimport type { Client, Scope, Span as SentrySpan, StartSpanOptions } from '@sentry/core';\nimport {\n getClient,\n getCurrentScope,\n getDynamicSamplingContextFromSpan,\n getRootSpan,\n handleCallbackErrors,\n hasSpansEnabled,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n spanToStaticSpanJSON,\n} from '@sentry/core';\nimport { getContextFromScope } from './utils/contextData';\nimport { getSamplingDecision } from './utils/getSamplingDecision';\nimport { makeTraceState } from './utils/makeTraceState';\nimport { reconcileDscSampled } from './utils/reconcileDscSampled';\nimport { SENTRY_TRACE_STATE_DSC } from './constants';\n\n/**\n * Internal helper for starting spans and manual spans. See {@link startSpan} and {@link startSpanManual} for the public APIs.\n * @param options - The span context options\n * @param callback - The callback to execute with the span\n * @param autoEnd - Whether to automatically end the span after the callback completes\n */\nfunction _startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T, autoEnd: boolean): T {\n const tracer = getTracer();\n\n const { name, parentSpan: customParentSpan } = options;\n\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const activeCtx = getContext(options.scope, options.forceTransaction);\n const missingRequiredParent = options.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = missingRequiredParent ? suppressTracing(activeCtx) : activeCtx;\n\n if (missingRequiredParent) {\n getClient()?.recordDroppedEvent('no_parent_span', 'span');\n }\n\n const spanOptions = getSpanOptions(options);\n\n // If spans are not enabled, ensure we suppress tracing for the span creation\n // but preserve the original context for the callback execution\n // This ensures that we don't create spans when tracing is disabled which\n // would otherwise be a problem for users that don't enable tracing but use\n // custom OpenTelemetry setups.\n if (!hasSpansEnabled()) {\n const suppressedCtx = isTracingSuppressed(ctx) ? ctx : suppressTracing(ctx);\n\n return context.with(suppressedCtx, () => {\n return tracer.startActiveSpan(name, spanOptions, suppressedCtx, span => {\n patchSpanEnd(span);\n // Run the callback under the original unsuppressed context (so custom OpenTelemetry spans\n // created inside are not suppressed) but with our span set as active. Without setting the\n // span here, `getActiveSpan()` inside the callback would resolve to a stale ancestor on\n // `activeCtx` (e.g. an outer span outside a `startNewTrace`/`continueTrace` boundary),\n // and event trace-context would attach to the wrong trace.\n // We use activeCtx (not ctx) because ctx may be suppressed when onlyIfParent is true\n // and no parent span exists. Using activeCtx ensures custom OTel spans are never\n // inadvertently suppressed.\n return context.with(trace.setSpan(activeCtx, span), () => {\n return handleCallbackErrors(\n () => callback(span),\n () => {\n // Only set the span status to ERROR when there wasn't any error status set before, in order to avoid stomping useful span statuses\n if (spanToStaticSpanJSON(span).status === 'ok') {\n span.setStatus({ code: SpanStatusCode.ERROR });\n }\n },\n autoEnd ? () => span.end() : undefined,\n );\n });\n });\n });\n }\n\n return tracer.startActiveSpan(name, spanOptions, ctx, span => {\n patchSpanEnd(span);\n return handleCallbackErrors(\n () => callback(span),\n () => {\n // Only set the span status to ERROR when there wasn't any error status set before, in order to avoid stomping useful span statuses\n if (spanToStaticSpanJSON(span).status === 'ok') {\n span.setStatus({ code: SpanStatusCode.ERROR });\n }\n },\n autoEnd ? () => span.end() : undefined,\n );\n });\n });\n}\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n return _startSpan(options, callback, true);\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a span, but does not finish the span\n * after the function is done automatically. You'll have to call `span.end()` or the `finish` function passed to the callback manually.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n return _startSpan(options, span => callback(span, () => span.end()), false);\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const tracer = getTracer();\n\n const { name, parentSpan: customParentSpan } = options;\n\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<Span>(customParentSpan);\n\n return wrapper(() => {\n const activeCtx = getContext(options.scope, options.forceTransaction);\n const missingRequiredParent = options.onlyIfParent && !trace.getSpan(activeCtx);\n let ctx = missingRequiredParent ? suppressTracing(activeCtx) : activeCtx;\n\n if (missingRequiredParent) {\n getClient()?.recordDroppedEvent('no_parent_span', 'span');\n }\n\n const spanOptions = getSpanOptions(options);\n\n if (!hasSpansEnabled()) {\n ctx = isTracingSuppressed(ctx) ? ctx : suppressTracing(ctx);\n }\n\n const span = tracer.startSpan(name, spanOptions, ctx);\n patchSpanEnd(span);\n return span;\n });\n}\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will be root spans.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const newContextWithActiveSpan = span ? trace.setSpan(context.active(), span) : trace.deleteSpan(context.active());\n return context.with(newContextWithActiveSpan, () => callback(getCurrentScope()));\n}\n\nfunction getTracer(): Tracer {\n // The node client has a `tracer` property, we use this if it exists, or else we use the global tracer\n const client = getClient<Client & { tracer?: Tracer }>();\n return client?.tracer || trace.getTracer('@sentry/opentelemetry', SDK_VERSION);\n}\n\nfunction getSpanOptions(options: StartSpanOptions): SpanOptions {\n const { startTime, attributes, op, links } = options;\n\n // OTEL expects timestamps in ms, not seconds\n const fixedStartTime = typeof startTime === 'number' ? ensureTimestampInMilliseconds(startTime) : startTime;\n\n return {\n attributes: op\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,\n ...attributes,\n }\n : attributes,\n links,\n startTime: fixedStartTime,\n };\n}\n\nfunction ensureTimestampInMilliseconds(timestamp: number): number {\n const isMs = timestamp < 9999999999;\n return isMs ? timestamp * 1000 : timestamp;\n}\n\n/**\n * Wraps the span's `end()` method so that numeric timestamps passed in seconds\n * are converted to milliseconds before reaching OTel's native `Span.end()`.\n */\nfunction patchSpanEnd(span: Span): void {\n const originalEnd = span.end.bind(span);\n span.end = (endTime?: TimeInput) => {\n return originalEnd(typeof endTime === 'number' ? ensureTimestampInMilliseconds(endTime) : endTime);\n };\n}\n\nfunction getContext(scope: Scope | undefined, forceTransaction: boolean | undefined): Context {\n const ctx = getContextForScope(scope);\n const parentSpan = trace.getSpan(ctx);\n\n // In the case that we have no parent span, we start a new trace\n // Note that if we continue a trace, we'll always have a remote parent span here anyhow\n if (!parentSpan) {\n return ctx;\n }\n\n // If we don't want to force a transaction, and we have a parent span, all good, we just return as-is!\n if (!forceTransaction) {\n return ctx;\n }\n\n // Else, if we do have a parent span but want to force a transaction, we have to simulate a \"root\" context\n\n // Else, we need to do two things:\n // 1. Unset the parent span from the context, so we'll create a new root span\n // 2. Ensure the propagation context is correct, so we'll continue from the parent span\n const ctxWithoutSpan = trace.deleteSpan(ctx);\n\n const { spanId, traceId } = parentSpan.spanContext();\n const sampled = getSamplingDecision(parentSpan.spanContext());\n\n // In this case, when we are forcing a transaction, we want to treat this like continuing an incoming trace\n // so we set the traceState according to the root span\n const rootSpan = getRootSpan(parentSpan);\n const rawDsc = getDynamicSamplingContextFromSpan(rootSpan);\n\n // When the root carried a frozen incoming DSC on its trace state, `getDynamicSamplingContextFromSpan`\n // returns it verbatim and it is immutable per the propagation spec. Otherwise core freshly derived the\n // DSC from the root's (binary) trace flags, which cannot tell a deferred decision apart from a\n // definitive unsampled one — reconcile `sampled` against the authoritative OTel decision so a deferred\n // parent (e.g. a `startNewTrace` remote parent with `traceFlags: NONE`) does not bake in `sampled=false`.\n const hasIncomingFrozenDsc = !!rootSpan.spanContext().traceState?.get(SENTRY_TRACE_STATE_DSC);\n const dsc = hasIncomingFrozenDsc ? rawDsc : reconcileDscSampled(rawDsc, sampled);\n\n const traceState = makeTraceState({\n dsc,\n sampled,\n });\n\n const spanOptions: SpanContext = {\n traceId,\n spanId,\n isRemote: true,\n traceFlags: sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,\n traceState,\n };\n\n const ctxWithSpanContext = trace.setSpanContext(ctxWithoutSpan, spanOptions);\n\n return ctxWithSpanContext;\n}\n\nfunction getContextForScope(scope?: Scope): Context {\n if (scope) {\n const ctx = getContextFromScope(scope);\n if (ctx) {\n return ctx;\n }\n }\n\n return context.active();\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | SentrySpan | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n","import type { Span } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport type { Scope } from '@sentry/core';\nimport { getContextFromScope } from './contextData';\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(scope?: Scope): Span | undefined {\n if (!scope) {\n return trace.getActiveSpan();\n }\n\n const ctx = getContextFromScope(scope);\n if (ctx) {\n return trace.getSpan(ctx);\n }\n\n // If ctx cannot be picked from scope, return undefined\n return undefined;\n}\n","import type { Context } from '@opentelemetry/api';\nimport type { Scope } from '@sentry/core';\nimport { getCurrentScope, getIsolationScope } from '@sentry/core';\nimport {\n SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY,\n SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY,\n SENTRY_FORK_SET_SCOPE_CONTEXT_KEY,\n} from '../constants';\nimport { getScopesFromContext, setContextOnScope, setScopesOnContext } from './contextData';\n\n/**\n * Merge Sentry scopes into an OpenTelemetry {@link Context} and apply trace-context adjustments\n * used by Sentry OpenTelemetry context manager(s).\n *\n * @param context - Context passed into `ContextManager.with`.\n * @param activeContext - Context that was active before entering `with` (e.g. `this.active()`), used\n * to restore the parent span when the incoming span is marked ignored for children.\n * @returns A new context ready for `super.with` / `AsyncLocalStorage.run`.\n */\nexport function buildContextWithSentryScopes(context: Context): Context {\n const currentScopes = getScopesFromContext(context);\n const currentScope = currentScopes?.scope || getCurrentScope();\n const currentIsolationScope = currentScopes?.isolationScope || getIsolationScope();\n\n const shouldForkIsolationScope = context.getValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY) === true;\n const scope = context.getValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY) as Scope | undefined;\n const isolationScope = context.getValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY) as Scope | undefined;\n\n const newCurrentScope = scope || currentScope.clone();\n const newIsolationScope =\n isolationScope || (shouldForkIsolationScope ? currentIsolationScope.clone() : currentIsolationScope);\n const scopes = { scope: newCurrentScope, isolationScope: newIsolationScope };\n\n const ctx1 = setScopesOnContext(context, scopes);\n\n const ctx2 = ctx1\n .deleteValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY)\n .deleteValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY)\n .deleteValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY);\n\n setContextOnScope(newCurrentScope, ctx2);\n\n return ctx2;\n}\n","/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * This implementation follows the behavior of OpenTelemetry’s `@opentelemetry/context-async-hooks`\n * package, combining logic that upstream splits across:\n * - https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts\n * - https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts\n * It is a single-class re-implementation for Sentry (not a verbatim copy of those files).\n */\n\nimport type { Context, ContextManager } from '@opentelemetry/api';\nimport { ROOT_CONTEXT } from '@opentelemetry/api';\nimport type { AsyncLocalStorage } from 'node:async_hooks';\nimport type { EventEmitter } from 'node:events';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from './constants';\nimport { buildContextWithSentryScopes } from './utils/buildContextWithSentryScopes';\n\nexport type AsyncLocalStorageLookup = {\n asyncLocalStorage: AsyncLocalStorage<unknown>;\n /**\n * The OpenTelemetry context key under which the `{ scope, isolationScope }` object is stored, for\n * native threads that read scope out of the AsyncLocalStorage (e.g. `@sentry/node-native`). Omitted\n * for the pure AsyncLocalStorage strategy, whose store already is that object.\n */\n contextSymbol?: symbol;\n};\ntype ListenerFn = (...args: unknown[]) => unknown;\n\n/**\n * Per-event map from user listeners to context-bound listeners.\n */\ntype PatchMap = Record<string, WeakMap<ListenerFn, ListenerFn>>;\n\nconst ADD_LISTENER_METHODS = ['addListener', 'on', 'once', 'prependListener', 'prependOnceListener'] as const;\n\n/**\n * OpenTelemetry-compatible context manager using Node.js `AsyncLocalStorage`.\n */\nexport class SentryAsyncLocalStorageContextManager implements ContextManager {\n protected readonly _asyncLocalStorage: AsyncLocalStorage<Context>;\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n\n public constructor(asyncLocalStorage: AsyncLocalStorage<Context>) {\n this._asyncLocalStorage = asyncLocalStorage;\n }\n\n public active(): Context {\n return this._asyncLocalStorage.getStore() ?? ROOT_CONTEXT;\n }\n\n public with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n const ctx2 = buildContextWithSentryScopes(context);\n const cb = thisArg == null ? fn : fn.bind(thisArg);\n return this._asyncLocalStorage.run(ctx2, cb as never, ...args);\n }\n\n public enable(): this {\n return this;\n }\n\n public disable(): this {\n try {\n this._asyncLocalStorage.disable();\n } catch {\n // we don't care if something goes wrong here\n }\n return this;\n }\n\n public bind<T>(context: Context, target: T): T {\n if (isEventEmitter(target)) {\n return this._bindEventEmitter(context, target);\n }\n if (typeof target === 'function') {\n return this._bindFunction(context, target as unknown as ListenerFn) as T;\n }\n return target;\n }\n\n /**\n * Gets underlying AsyncLocalStorage and symbol to allow lookup of scope.\n * This is Sentry-specific.\n */\n public getAsyncLocalStorageLookup(): AsyncLocalStorageLookup {\n return {\n asyncLocalStorage: this._asyncLocalStorage,\n contextSymbol: SENTRY_SCOPES_CONTEXT_KEY,\n };\n }\n\n private _bindFunction(context: Context, target: ListenerFn): ListenerFn {\n const managerWith = this.with.bind(this);\n const contextWrapper = function (this: never, ...args: unknown[]) {\n return managerWith(context, () => target.apply(this, args));\n };\n Object.defineProperty(contextWrapper, 'length', {\n enumerable: false,\n configurable: true,\n writable: false,\n value: target.length,\n });\n return contextWrapper;\n }\n\n private _bindEventEmitter<T extends EventEmitter>(context: Context, ee: T): T {\n if (this._getPatchMap(ee) !== undefined) {\n return ee;\n }\n if (this._createPatchMap(ee) === undefined) {\n return ee;\n }\n\n for (const methodName of ADD_LISTENER_METHODS) {\n const original = getMethod(ee, methodName);\n if (!original) continue;\n trySetMethod(ee, methodName, this._patchAddListener(ee, original, context));\n }\n for (const methodName of ['removeListener', 'off'] as const) {\n const original = getMethod(ee, methodName);\n if (!original) continue;\n trySetMethod(ee, methodName, this._patchRemoveListener(ee, original));\n }\n const removeAllListeners = getMethod(ee, 'removeAllListeners');\n if (removeAllListeners) {\n trySetMethod(ee, 'removeAllListeners', this._patchRemoveAllListeners(ee, removeAllListeners));\n }\n return ee;\n }\n\n private _patchRemoveListener(ee: EventEmitter, original: (...args: unknown[]) => unknown) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event: string, listener: ListenerFn) {\n const events = contextManager._getPatchMap(ee)?.[event];\n if (events === undefined) {\n return original.call(this, event, listener);\n }\n const patchedListener = events.get(listener);\n return original.call(this, event, patchedListener || listener);\n };\n }\n\n private _patchRemoveAllListeners(ee: EventEmitter, original: (...args: unknown[]) => unknown) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event?: string) {\n const map = contextManager._getPatchMap(ee);\n if (map !== undefined) {\n if (arguments.length === 0) {\n // Best-effort reset: if the emitter was frozen after binding, this cannot replace the map\n // (and the map itself could not be cleared in place either). A stale map is harmless though —\n // `_patchAddListener` overwrites entries when a listener is re-added, and `_patchRemoveListener`\n // passing an already-unregistered wrapper to `original` is a no-op.\n contextManager._createPatchMap(ee);\n } else if (event !== undefined && map[event] !== undefined) {\n // oxlint-disable-next-line @typescript-eslint/no-dynamic-delete -- event-keyed listener map\n delete map[event];\n }\n }\n return original.apply(this, arguments);\n };\n }\n\n private _patchAddListener(ee: EventEmitter, original: (...args: unknown[]) => unknown, context: Context) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event: string, listener: ListenerFn) {\n if (contextManager._wrapped) {\n return original.call(this, event, listener);\n }\n const map = contextManager._getPatchMap(ee) ?? contextManager._createPatchMap(ee);\n if (map === undefined) {\n return original.call(this, event, listener);\n }\n let listeners = map[event];\n if (listeners === undefined) {\n listeners = new WeakMap();\n map[event] = listeners;\n }\n const patchedListener = contextManager.bind(context, listener);\n listeners.set(listener, patchedListener);\n\n contextManager._wrapped = true;\n try {\n return original.call(this, event, patchedListener);\n } finally {\n contextManager._wrapped = false;\n }\n };\n }\n\n /**\n * Attach a fresh patch map to the emitter. Returns `undefined` if the emitter does not accept the\n * property (e.g. it is frozen or sealed), in which case the emitter must not be patched at all —\n * without a patch map the remove-listener patches could not resolve their wrapped listeners.\n */\n private _createPatchMap(ee: EventEmitter): PatchMap | undefined {\n const map = Object.create(null) as PatchMap;\n try {\n (ee as unknown as Record<symbol, PatchMap>)[this._kOtListeners] = map;\n } catch {\n return undefined;\n }\n return this._getPatchMap(ee) === map ? map : undefined;\n }\n\n private _getPatchMap(ee: EventEmitter): PatchMap | undefined {\n return (ee as unknown as Record<symbol, PatchMap | undefined>)[this._kOtListeners];\n }\n}\n\n/**\n * Duck-typed `EventEmitter` check.\n *\n * We use this instead of `instanceof EventEmitter` so it also works in non-Node.js environments (e.g. vercel-edge)\n * and across realms. Both `on` and `emit` must be callable — checking only for the presence of an `on` property\n * would classify plain objects like `{ on: true }` as emitters and later try to call a non-function.\n */\nfunction isEventEmitter(target: unknown): target is EventEmitter {\n if (typeof target !== 'object' || !target) {\n return false;\n }\n const candidate = target as Partial<Record<'on' | 'emit', unknown>>;\n return typeof candidate.on === 'function' && typeof candidate.emit === 'function';\n}\n\n/**\n * Read a method off an emitter, ignoring inherited or own properties that are not callable.\n */\nfunction getMethod<T extends EventEmitter>(ee: T, methodName: keyof EventEmitter): ListenerFn | undefined {\n const value = (ee as unknown as Record<string, unknown>)[methodName as string];\n return typeof value === 'function' ? (value as ListenerFn) : undefined;\n}\n\n/**\n * Assign a patched method back onto the emitter. Emitters may be frozen or expose getter-only methods,\n * in which case we leave the original method in place instead of throwing.\n */\nfunction trySetMethod<T extends EventEmitter>(\n ee: T,\n methodName: keyof EventEmitter,\n patched: (...args: never[]) => unknown,\n): void {\n try {\n (ee as unknown as Record<string, unknown>)[methodName as string] = patched;\n } catch {\n // Nothing to do, the emitter keeps its unpatched method\n }\n}\n","import * as api from '@opentelemetry/api';\nimport type { Scope, TracingChannelBinding } from '@sentry/core';\nimport {\n getAsyncContextStrategy,\n _INTERNAL_safeMathRandom,\n generateTraceId,\n getDefaultCurrentScope,\n getDefaultIsolationScope,\n getMainCarrier,\n isContinuingTrace,\n setAsyncContextStrategy,\n} from '@sentry/core';\nimport {\n SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY,\n SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY,\n SENTRY_FORK_SET_SCOPE_CONTEXT_KEY,\n} from './constants';\nimport { startInactiveSpan, startSpan, startSpanManual, withActiveSpan } from './trace';\nimport type { CurrentScopes } from './types';\nimport { getContextFromScope, getScopesFromContext } from './utils/contextData';\nimport { getActiveSpan } from './utils/getActiveSpan';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport type { AsyncLocalStorageLookup } from './asyncLocalStorageContextManager';\nimport { SentryAsyncLocalStorageContextManager } from './asyncLocalStorageContextManager';\n\n/**\n * Sets the async context strategy to use follow the OTEL context under the hood.\n * We handle forking a hub inside of our custom OTEL Context Manager (./otelContextManager.ts)\n */\nexport function setOpenTelemetryContextAsyncContextStrategy(): AsyncLocalStorageLookup {\n // Re-use the AsyncLocalStorage of an already-installed strategy, if any. Otherwise a repeated\n // setup would swap in a new store while integrations that captured the previous one (via\n // `getTracingChannelBinding().asyncLocalStorage`) keep reading the old one, breaking scope\n // propagation across async boundaries.\n const existingAsyncLocalStorage = getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.()\n ?.asyncLocalStorage as AsyncLocalStorage<api.Context> | undefined;\n\n const asyncLocalStorage = existingAsyncLocalStorage ?? new AsyncLocalStorage<api.Context>();\n\n function getScopes(): CurrentScopes {\n const ctx = api.context.active();\n const scopes = getScopesFromContext(ctx);\n\n if (scopes) {\n return scopes;\n }\n\n // fallback behavior:\n // if, for whatever reason, we can't find scopes on the context here, we have to fix this somehow\n return {\n scope: getDefaultCurrentScope(),\n isolationScope: getDefaultIsolationScope(),\n };\n }\n\n function withScope<T>(callback: (scope: Scope) => T): T {\n const ctx = api.context.active();\n\n // We depend on the otelContextManager to handle the context/hub\n // We set the `SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY` context value, which is picked up by\n // the OTEL context manager, which uses the presence of this key to determine if it should\n // fork the isolation scope, or not\n // as by default, we don't want to fork this, unless triggered explicitly by `withScope`\n return api.context.with(ctx, () => {\n return callback(getCurrentScope());\n });\n }\n\n function withSetScope<T>(scope: Scope, callback: (scope: Scope) => T): T {\n const ctx = getContextFromScope(scope) || api.context.active();\n\n // We depend on the otelContextManager to handle the context/hub\n // We set the `SENTRY_FORK_SET_SCOPE_CONTEXT_KEY` context value, which is picked up by\n // the OTEL context manager, which picks up this scope as the current scope\n return api.context.with(ctx.setValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY, scope), () => {\n return callback(scope);\n });\n }\n\n function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T {\n const ctx = api.context.active();\n\n // We depend on the otelContextManager to handle the context/hub\n // We set the `SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY` context value, which is picked up by\n // the OTEL context manager, which uses the presence of this key to determine if it should\n // fork the isolation scope, or not\n return api.context.with(ctx.setValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY, true), () => {\n // When forking an isolation scope, unless we are continuing an incoming\n // trace, we give the freshly forked scope its own trace. This way, new\n // root spans in an isolation scope will get separate traces. The\n // previous trace's `sampled` and `propagationSpanId` are dropped on\n // purpose. Carrying them over would apply the old trace's sampling\n // decision to the new one and propagate a span id from a different trace.\n const scope = getCurrentScope();\n if (!isContinuingTrace(scope.getPropagationContext())) {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: _INTERNAL_safeMathRandom(),\n });\n }\n return callback(getIsolationScope());\n });\n }\n\n function withSetIsolationScope<T>(isolationScope: Scope, callback: (isolationScope: Scope) => T): T {\n const ctx = api.context.active();\n\n // We depend on the otelContextManager to handle the context/hub\n // We set the `SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY` context value, which is picked up by\n // the OTEL context manager, which uses the presence of this key to determine if it should\n // fork the isolation scope, or not\n return api.context.with(ctx.setValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, isolationScope), () => {\n return callback(getIsolationScope());\n });\n }\n\n function getCurrentScope(): Scope {\n return getScopes().scope;\n }\n\n function getIsolationScope(): Scope {\n return getScopes().isolationScope;\n }\n\n function getTracingChannelBinding(): TracingChannelBinding {\n return {\n asyncLocalStorage,\n };\n }\n\n setAsyncContextStrategy({\n withScope,\n withSetScope,\n withSetIsolationScope,\n withIsolationScope,\n getCurrentScope,\n getIsolationScope,\n startSpan,\n startSpanManual,\n startInactiveSpan,\n getActiveSpan,\n // The types here don't fully align, because our own `Span` type is narrower\n // than the OTEL one - but this is OK for here, as we now we'll only have OTEL spans passed around\n withActiveSpan: withActiveSpan,\n getTracingChannelBinding,\n });\n\n const ctxManager = new SentryAsyncLocalStorageContextManager(asyncLocalStorage);\n api.context.setGlobalContextManager(ctxManager);\n\n return ctxManager.getAsyncLocalStorageLookup();\n}\n"],"names":["isTracingSuppressed"],"mappings":";;;;;;AAKO,MAAM,sBAAA,GAAyB,YAAA;AAC/B,MAAM,wCAAA,GAA2C,8BAAA;AAEjD,MAAM,yBAAA,GAA4B,iBAAiB,eAAe,CAAA;AAElE,MAAM,uCAAA,GAA0C,iBAAiB,6BAA6B,CAAA;AAE9F,MAAM,iCAAA,GAAoC,iBAAiB,uBAAuB,CAAA;AAElF,MAAM,2CAAA,GAA8C,iBAAiB,iCAAiC,CAAA;;ACR7G,MAAM,mBAAA,GAAsB,SAAA;AAMrB,SAAS,qBAAqB,OAAA,EAA6C;AAChF,EAAA,OAAO,OAAA,CAAQ,SAAS,yBAAyB,CAAA;AACnD;AAMO,SAAS,kBAAA,CAAmB,SAAkB,MAAA,EAAgC;AACnF,EAAA,OAAO,OAAA,CAAQ,QAAA,CAAS,yBAAA,EAA2B,MAAM,CAAA;AAC3D;AAYO,SAAS,iBAAA,CA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A;AAAA,IACrC,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,SAAS,eAAA,GAAyB;AAChC,IAAA,OAAO,WAAU,CAAE,KAAA;AAAA,EACrB;AAEA,EAAA,SAAS,iBAAA,GAA2B;AAClC,IAAA,OAAO,WAAU,CAAE,cAAA;AAAA,EACrB;AAEA,EAAA,SAAS,wBAAA,GAAkD;AACzD,IAAA,OAAO;AAAA,MACL;AAAA,KACF;AAAA,EACF;AAEA,EAAA,uBAAA,CAAwB;AAAA,IACtB,SAAA;AAAA,IACA,YAAA;AAAA,IACA,qBAAA;AAAA,IACA,kBAAA;AAAA,IACA,eAAA;AAAA,IACA,iBAAA;AAAA,IACA,SAAA;AAAA,IACA,eAAA;AAAA,IACA,iBAAA;AAAA,IACA,aAAA;AAAA;AAAA;AAAA,IAGA,cAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAM,UAAA,GAAa,IAAI,qCAAA,CAAsC,iBAAiB,CAAA;AAC9E,EAAA,GAAA,CAAI,OAAA,CAAQ,wBAAwB,UAAU,CAAA;AAE9C,EAAA,OAAO,WAAW,0BAAA,EAA2B;AAC/C;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/constants.ts","../../src/utils/contextData.ts","../../src/utils/TraceState.ts","../../src/utils/makeTraceState.ts","../../src/propagator.ts","../../src/utils/suppressTracing.ts","../../src/tracer.ts","../../src/tracerProvider.ts","../../src/trace.ts","../../src/utils/getActiveSpan.ts","../../src/utils/buildContextWithSentryScopes.ts","../../src/asyncLocalStorageContextManager.ts","../../src/asyncContextStrategy.ts","../../src/utils/getSamplingDecision.ts","../../src/prepareSpanScope.ts"],"sourcesContent":["import { createContextKey } from '@opentelemetry/api';\n\nexport const SENTRY_TRACE_HEADER = 'sentry-trace';\nexport const SENTRY_BAGGAGE_HEADER = 'baggage';\n\nexport const SENTRY_TRACE_STATE_DSC = 'sentry.dsc';\nexport const SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING = 'sentry.sampled_not_recording';\n\nexport const SENTRY_SCOPES_CONTEXT_KEY = createContextKey('sentry_scopes');\n\nexport const SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY = createContextKey('sentry_fork_isolation_scope');\n\nexport const SENTRY_FORK_SET_SCOPE_CONTEXT_KEY = createContextKey('sentry_fork_set_scope');\n\nexport const SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY = createContextKey('sentry_fork_set_isolation_scope');\n","import type { Context } from '@opentelemetry/api';\nimport type { Scope } from '@sentry/core';\nimport { derefWeakRef, makeWeakRef, type MaybeWeakRef } from '@sentry/core';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from '../constants';\nimport type { CurrentScopes } from '../types';\n\nconst SCOPE_CONTEXT_FIELD = 'context';\n\n/**\n * Try to get the current scopes from the given OTEL context.\n * This requires a Context Manager that was wrapped with getWrappedContextManager.\n */\nexport function getScopesFromContext(context: Context): CurrentScopes | undefined {\n return context.getValue(SENTRY_SCOPES_CONTEXT_KEY) as CurrentScopes | undefined;\n}\n\n/**\n * Set the current scopes on an OTEL context.\n * This will return a forked context with the Propagation Context set.\n */\nexport function setScopesOnContext(context: Context, scopes: CurrentScopes): Context {\n return context.setValue(SENTRY_SCOPES_CONTEXT_KEY, scopes);\n}\n\n/**\n * Set the context on the scope so we can later look it up.\n * We need this to get the context from the scope in the `trace` functions.\n *\n * We use WeakRef to avoid a circular reference between the scope and the context.\n * The context holds scopes (via SENTRY_SCOPES_CONTEXT_KEY), and if the scope held\n * a strong reference back to the context, neither could be garbage collected even\n * when the context is no longer reachable from application code (e.g., after a\n * request completes but pooled connections retain patched callbacks).\n */\nexport function setContextOnScope(scope: Scope, context: Context): void {\n scope.refs[SCOPE_CONTEXT_FIELD] = makeWeakRef(context);\n}\n\n/**\n * Get the context related to a scope.\n * Returns undefined if the context has been garbage collected (when WeakRef is used).\n */\nexport function getContextFromScope(scope: Scope): Context | undefined {\n return derefWeakRef(scope.refs[SCOPE_CONTEXT_FIELD] as MaybeWeakRef<Context> | undefined);\n}\n","/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Minimal vendored implementation of `TraceState` from `@opentelemetry/core`\n * to avoid pulling in that dependency for a single class.\n * - Drops raw-string parsing and key/value validation, neither of which are\n * used by the SDK — the W3C `tracestate` header is parsed by OTel's own\n * propagators (which use their own `TraceState`), and every key we `set`\n * is a known constant.\n */\nimport type { TraceState as TraceStateInterface } from '@opentelemetry/api';\n\n/**\n * Minimal implementation of the W3C `tracestate` field as a `@opentelemetry/api`\n * `TraceState`. New entries are inserted at the front of the list, and updating\n * an existing key moves it to the front.\n *\n * See https://www.w3.org/TR/trace-context/#tracestate-field for the field spec.\n */\nexport class TraceState implements TraceStateInterface {\n private _internalState: Map<string, string> = new Map();\n\n /** @inheritDoc */\n public set(key: string, value: string): TraceState {\n const next = this._clone();\n if (next._internalState.has(key)) {\n next._internalState.delete(key);\n }\n next._internalState.set(key, value);\n return next;\n }\n\n /** @inheritDoc */\n public unset(key: string): TraceState {\n const next = this._clone();\n next._internalState.delete(key);\n return next;\n }\n\n /** @inheritDoc */\n public get(key: string): string | undefined {\n return this._internalState.get(key);\n }\n\n /** @inheritDoc */\n public serialize(): string {\n return Array.from(this._internalState.keys())\n .reverse()\n .map(key => `${key}=${this._internalState.get(key)}`)\n .join(',');\n }\n\n private _clone(): TraceState {\n const next = new TraceState();\n next._internalState = new Map(this._internalState);\n return next;\n }\n}\n","import type { DynamicSamplingContext } from '@sentry/core';\nimport { dynamicSamplingContextToSentryBaggageHeader } from '@sentry/core';\nimport { SENTRY_TRACE_STATE_DSC, SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING } from '../constants';\nimport { TraceState } from './TraceState';\n\n/**\n * Generate a TraceState for the given data.\n */\nexport function makeTraceState({\n dsc,\n sampled,\n}: {\n dsc?: Partial<DynamicSamplingContext>;\n sampled?: boolean;\n}): TraceState {\n // We store the DSC as OTEL trace state on the span context\n const dscString = dsc ? dynamicSamplingContextToSentryBaggageHeader(dsc) : undefined;\n\n const traceStateBase = new TraceState();\n\n const traceStateWithDsc = dscString ? traceStateBase.set(SENTRY_TRACE_STATE_DSC, dscString) : traceStateBase;\n\n // We also specifically want to store if this is sampled to be not recording,\n // or unsampled (=could be either sampled or not)\n return sampled === false ? traceStateWithDsc.set(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING, '1') : traceStateWithDsc;\n}\n","import type { Context, SpanContext, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';\nimport { context, trace, TraceFlags } from '@opentelemetry/api';\nimport type { continueTrace, DynamicSamplingContext } from '@sentry/core';\nimport {\n _INTERNAL_safeMathRandom,\n baggageHeaderToDynamicSamplingContext,\n consoleSandbox,\n generateTraceId,\n getClient,\n getCurrentScope,\n getIsolationScope,\n getTraceData,\n isTracingSuppressed,\n propagationContextFromHeaders,\n shouldContinueTrace,\n} from '@sentry/core';\nimport { getScopesFromContext, setScopesOnContext } from './utils/contextData';\nimport { makeTraceState } from './utils/makeTraceState';\n\nconst SENTRY_TRACE_HEADER = 'sentry-trace';\nconst SENTRY_BAGGAGE_HEADER = 'baggage';\nconst W3C_TRACEPARENT_HEADER = 'traceparent';\n\n/**\n * A minimal OpenTelemetry `TextMapPropagator` that injects and extracts Sentry trace data.\n *\n * This propagator only supports injecting/extracting from current context, for simplicity sake.\n * It will bail and do nothing if using a different context.\n */\nexport class SentryPropagator implements TextMapPropagator {\n /** @inheritDoc */\n public inject(ctx: Context, carrier: unknown, setter: TextMapSetter): void {\n if (ctx !== context.active()) {\n consoleSandbox(() => {\n // oxlint-disable-next-line no-console\n console.warn(\n 'SentryPropagator: Injecting trace data of a different context than the active one is not supported. Skipping injection.',\n );\n });\n return;\n }\n\n if (isTracingSuppressed()) {\n return;\n }\n\n const { propagateTraceparent } = getClient()?.getOptions() ?? {};\n\n // Pick trace data from the current scope\n const { 'sentry-trace': sentryTrace, baggage, traceparent } = getTraceData({ propagateTraceparent });\n\n if (sentryTrace) {\n setter.set(carrier, SENTRY_TRACE_HEADER, sentryTrace);\n }\n if (baggage) {\n setter.set(carrier, SENTRY_BAGGAGE_HEADER, baggage);\n }\n if (traceparent) {\n setter.set(carrier, W3C_TRACEPARENT_HEADER, traceparent);\n }\n }\n\n /** @inheritDoc */\n public extract(ctx: Context, carrier: unknown, getter: TextMapGetter): Context {\n const maybeSentryTraceHeader: string | string[] | undefined = getter.get(carrier, SENTRY_TRACE_HEADER);\n const baggage = getter.get(carrier, SENTRY_BAGGAGE_HEADER);\n\n const sentryTrace = Array.isArray(maybeSentryTraceHeader) ? maybeSentryTraceHeader[0] : maybeSentryTraceHeader;\n\n // Add remote parent span context. If there is no incoming trace, this returns the context as-is.\n return getContextWithRemoteActiveSpanAndScopes(ctx, { sentryTrace, baggage });\n }\n\n /** @inheritDoc */\n public fields(): string[] {\n return [SENTRY_TRACE_HEADER, SENTRY_BAGGAGE_HEADER, W3C_TRACEPARENT_HEADER];\n }\n}\n\nfunction getContextWithRemoteActiveSpan(\n ctx: Context,\n { sentryTrace, baggage }: Parameters<typeof continueTrace>[0],\n): Context {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n\n const { traceId, parentSpanId, sampled, dsc } = propagationContext;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n\n // We only want to set the virtual span if we are continuing a concrete trace\n // Otherwise, we ignore the incoming trace here, e.g. if we have no trace headers\n if (!parentSpanId || (client && !shouldContinueTrace(client, incomingDsc?.org_id))) {\n return ctx;\n }\n\n const spanContext = generateRemoteSpanContext({\n traceId,\n spanId: parentSpanId,\n sampled,\n dsc,\n });\n\n return trace.setSpanContext(ctx, spanContext);\n}\n\n/**\n * Build a context that continues an incoming trace as a remote active span, with scopes ensured.\n * Returns the context so it can be used to implement an OpenTelemetry propagator's `extract`.\n */\nfunction getContextWithRemoteActiveSpanAndScopes(ctx: Context, options: Parameters<typeof continueTrace>[0]): Context {\n const ctxWithRemoteSpan = getContextWithRemoteActiveSpan(ctx, options);\n // If a remote active span was set, we are continuing an incoming trace, so the trace id is fixed.\n // Otherwise there was no (valid) incoming trace and we are the head of a new trace.\n const isContinuingTrace = trace.getSpanContext(ctxWithRemoteSpan) !== undefined;\n return ensureScopesOnContext(ctxWithRemoteSpan, isContinuingTrace);\n}\n\nfunction ensureScopesOnContext(ctx: Context, isContinuingTrace: boolean): Context {\n // If there are no scopes yet on the context, ensure we have them\n const scopes = getScopesFromContext(ctx);\n\n // If we have no scope here, this is most likely either the root context or a context manually derived from it\n // In this case, we want to fork the current scope, to ensure we do not pollute the root scope\n const scope = scopes ? scopes.scope : getCurrentScope().clone();\n\n // When we forked a fresh scope and are not continuing an incoming trace, we give it its own trace.\n // Without this, concurrent header-less requests (e.g. edge middleware, whose root span is created by\n // upstream OTEL instrumentation rather than through `continueTrace`) would all inherit the forked\n // scope's trace id and collapse into a single trace. Mirrors `continueTrace` in the core HTTP server.\n if (!scopes && !isContinuingTrace) {\n const propagationContext = scope.getPropagationContext();\n scope.setPropagationContext({\n ...propagationContext,\n traceId: generateTraceId(),\n sampleRand: _INTERNAL_safeMathRandom(),\n });\n }\n\n const newScopes = {\n scope,\n isolationScope: scopes ? scopes.isolationScope : getIsolationScope(),\n };\n\n return setScopesOnContext(ctx, newScopes);\n}\n\nfunction generateRemoteSpanContext({\n spanId,\n traceId,\n sampled,\n dsc,\n}: {\n spanId: string;\n traceId: string;\n sampled: boolean | undefined;\n dsc?: Partial<DynamicSamplingContext>;\n}): SpanContext {\n // We store the DSC as OTEL trace state on the span context\n const traceState = makeTraceState({\n dsc,\n sampled,\n });\n\n const spanContext: SpanContext = {\n traceId,\n spanId,\n isRemote: true,\n traceFlags: sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,\n traceState,\n };\n\n return spanContext;\n}\n","/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Minimal vendored implementation of the tracing-suppression helpers from\n * `@opentelemetry/core` to avoid pulling in that dependency.\n * - The context key string must stay byte-identical to OTel's, since other\n * OpenTelemetry instrumentation (e.g. `@opentelemetry/instrumentation-http`)\n * writes to the same key and our tracer reads it back to suppress spans.\n * - `unsuppressTracing` is dropped, as the SDK never removes the flag.\n */\nimport type { Context } from '@opentelemetry/api';\nimport { createContextKey } from '@opentelemetry/api';\n\nconst SUPPRESS_TRACING_KEY = createContextKey('OpenTelemetry SDK Context Key SUPPRESS_TRACING');\n\n/** Returns a new context with tracing suppressed, so no spans are created within it. */\nexport function suppressTracing(context: Context): Context {\n return context.setValue(SUPPRESS_TRACING_KEY, true);\n}\n\n/** Whether tracing is suppressed in the given context. */\nexport function isTracingSuppressed(context: Context): boolean {\n return context.getValue(SUPPRESS_TRACING_KEY) === true;\n}\n","import type { Context, Span as OpenTelemetrySpan, SpanOptions, Tracer } from '@opentelemetry/api';\nimport { context, isSpanContextValid, trace } from '@opentelemetry/api';\nimport { isTracingSuppressed } from './utils/suppressTracing';\nimport {\n _INTERNAL_setSpanForScope,\n startInactiveSpan,\n addChildSpanToSpan,\n getActiveSpan,\n getCapturedScopesOnSpan,\n getCurrentScope,\n getIsolationScope,\n markSpanAsTracerProviderSpan,\n SentryNonRecordingSpan,\n setCapturedScopesOnSpan,\n spanIsIgnored,\n spanKindToName,\n startNewTrace,\n withScope,\n} from '@sentry/core';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport { SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY } from './constants';\nimport { SENTRY_KIND } from '@sentry/conventions/attributes';\n\nexport class SentryTracer implements Tracer {\n /** @inheritdoc */\n public startSpan(name: string, options: SpanOptions = {}, ctx?: Context): OpenTelemetrySpan {\n const parentContext = ctx || context.active();\n const parentSpanCandidate = options.root ? undefined : trace.getSpan(parentContext);\n // Ignore an invalid parent (e.g. a malformed incoming trace/span id) and start a fresh trace,\n // matching the OTel SDK sampler's `getValidSpan` behaviour.\n const parentSpan =\n parentSpanCandidate && isSpanContextValid(parentSpanCandidate.spanContext()) ? parentSpanCandidate : undefined;\n\n if (isTracingSuppressed(parentContext)) {\n return this._createNonRecordingSpan(parentSpan);\n }\n\n const span = this._startSentrySpan(name, options, parentSpan, ctx !== undefined);\n\n // Mark the span as provider-created so it becomes immutable after `end()` like an OTel SDK span\n // (see `SentrySpan.end()`). Spans created directly through the core API (e.g. the browser SDK)\n // are not marked and keep their mutable behavior.\n markSpanAsTracerProviderSpan(span);\n\n return span;\n }\n\n /** @inheritdoc */\n public startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, fn: F): ReturnType<F>;\n public startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(\n name: string,\n options: SpanOptions,\n fn: F,\n ): ReturnType<F>;\n public startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(\n name: string,\n options: SpanOptions,\n ctx: Context,\n fn: F,\n ): ReturnType<F>;\n public startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(\n name: string,\n optionsOrFn: SpanOptions | F,\n contextOrFn?: Context | F,\n fn?: F,\n ): ReturnType<F> {\n const options = typeof optionsOrFn === 'function' ? {} : optionsOrFn;\n const explicitCtx = typeof contextOrFn === 'function' || contextOrFn === undefined ? undefined : contextOrFn;\n const ctx = explicitCtx ?? context.active();\n const callback = (\n typeof optionsOrFn === 'function' ? optionsOrFn : typeof contextOrFn === 'function' ? contextOrFn : fn\n ) as F;\n\n // Only forward a context the caller actually passed. Forwarding the resolved `context.active()`\n // instead would read as an explicit root request on runtimes without an OTel context manager\n // (e.g. Cloudflare), where `context.active()` is always `ROOT_CONTEXT`, detaching every span\n // from the Sentry active span instead of nesting under it.\n const span = this.startSpan(name, options, explicitCtx);\n\n // Run the span's callback under the isolation scope captured when the span was created, so scope state\n // used or set during the span (tags, breadcrumbs, captured errors) belongs to that span and stays\n // isolated from other concurrent work. Without this it can land on a different isolation scope. This\n // holds for ignored spans too, which run the callback without ever becoming the active span.\n const capturedIsolationScope = getCapturedScopesOnSpan(span).isolationScope;\n const withCapturedIsolationScope = (contextToFork: Context): Context =>\n capturedIsolationScope\n ? contextToFork.setValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, capturedIsolationScope)\n : contextToFork;\n\n // Mirror core's `startSpan`: an ignored (`ignoreSpans`) span that has a parent must not become the\n // active span. Otherwise its children would attach to it and, since it's non-recording, be dropped\n // along with it (cascading the drop down the whole subtree). Leaving the parent active lets the\n // children attach to it and get re-parented instead. An ignored root span has no parent and still\n // becomes active, so its subtree is dropped as intended.\n if (spanIsIgnored(span) && this._hasParentSpan(options, explicitCtx)) {\n return context.with(withCapturedIsolationScope(ctx), () => callback(span)) as ReturnType<F>;\n }\n\n return context.with(withCapturedIsolationScope(trace.setSpan(ctx, span)), () => {\n // Without an OTel context manager (e.g. Cloudflare) `context.with` runs the callback directly and\n // nothing forks the scope, so setting the span on the current scope would leak it past the callback.\n // Fork explicitly in that case so the previously active span is restored afterwards.\n if (trace.getSpan(context.active()) !== span) {\n return withScope(scope => {\n _INTERNAL_setSpanForScope(scope, span);\n return callback(span) as ReturnType<F>;\n });\n }\n\n _INTERNAL_setSpanForScope(getCurrentScope(), span);\n return callback(span) as ReturnType<F>;\n });\n }\n\n /**\n * Whether a span started with these arguments gets a parent. Mirrors the parent lookup in `startSpan`\n * plus core's fallback to the scope's active span, which is what parents the span on runtimes without an\n * OTel context manager.\n */\n private _hasParentSpan(options: SpanOptions, explicitCtx: Context | undefined): boolean {\n if (options.root) {\n return false;\n }\n const parentSpan = explicitCtx ? trace.getSpan(explicitCtx) : getActiveSpan();\n return !!parentSpan && isSpanContextValid(parentSpan.spanContext());\n }\n\n private _startSentrySpan(\n name: string,\n options: SpanOptions,\n parentSpan: OpenTelemetrySpan | undefined,\n hasExplicitContext: boolean,\n ): Span {\n const sentryOptions = {\n name,\n attributes: (options.attributes as SpanAttributes) || {},\n links: options.links,\n startTime: options.startTime,\n };\n\n // Convert otel kind to our sentry.kind attribtue\n if (options.kind) {\n sentryOptions.attributes[SENTRY_KIND] = spanKindToName(options.kind);\n }\n\n if (options.root) {\n return startNewTrace(() => startInactiveSpan({ ...sentryOptions, parentSpan: null }));\n }\n\n if (parentSpan) {\n // Remote parents are handled by core: it continues their trace and starts a root span.\n return startInactiveSpan({ ...sentryOptions, parentSpan: parentSpan });\n }\n\n // No parent span and no remote parent: this is a fresh root span.\n return startInactiveSpan({\n ...sentryOptions,\n parentSpan: hasExplicitContext ? null : undefined,\n });\n }\n\n private _createNonRecordingSpan(parentSpan: OpenTelemetrySpan | undefined): OpenTelemetrySpan {\n // Without a parent, fall back to the current scope's propagation context trace id, so that\n // non-recording spans (TwP mode) stay on the trace set by `startNewTrace`/`continueTrace`\n // instead of minting a fresh random trace id. Mirrors core's `createChildOrRootSpan` TwP branch.\n const traceId = parentSpan?.spanContext().traceId ?? getCurrentScope().getPropagationContext().traceId;\n const span = new SentryNonRecordingSpan({ traceId });\n // Link to the parent (like core's `createChildOrRootSpan`) so `getRootSpan` and DSC\n // resolution reach the parent. Non-recording spans no longer carry a `parentSpanId`.\n if (parentSpan) {\n addChildSpanToSpan(parentSpan, span);\n }\n // Capture the scopes (mirroring `createChildOrRootSpan`) so `startActiveSpan` can\n // fork the isolation scope onto the OTel context for work inside a suppressed span.\n setCapturedScopesOnSpan(span, getCurrentScope(), getIsolationScope());\n return span;\n }\n}\n","import type { Tracer, TracerOptions, TracerProvider } from '@opentelemetry/api';\nimport { SentryTracer } from './tracer';\n\n/**\n * A minimal OpenTelemetry TracerProvider which creates native Sentry spans.\n */\nexport class SentryTracerProvider implements TracerProvider {\n private readonly _tracers = new Map<string, SentryTracer>();\n\n /** @inheritdoc */\n public getTracer(name: string, version?: string, options?: TracerOptions): Tracer {\n const key = JSON.stringify([name, version, options]);\n const cachedTracer = this._tracers.get(key);\n if (cachedTracer) {\n return cachedTracer;\n }\n\n const tracer = new SentryTracer();\n this._tracers.set(key, tracer);\n return tracer;\n }\n\n /** Compatibility with SDK tracer providers. */\n public forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n /** Compatibility with SDK tracer providers. */\n public shutdown(): Promise<void> {\n return Promise.resolve();\n }\n}\n","import type { Span } from '@opentelemetry/api';\nimport { context, trace } from '@opentelemetry/api';\nimport type { Scope } from '@sentry/core';\nimport { _INTERNAL_setSpanForScope, getCurrentScope } from '@sentry/core';\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will be root spans.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const newContextWithActiveSpan = span ? trace.setSpan(context.active(), span) : trace.deleteSpan(context.active());\n\n return context.with(newContextWithActiveSpan, () => {\n const scope = getCurrentScope();\n // Keep the scope's span in sync with the context, like `SentryTracer.startActiveSpan` does.\n _INTERNAL_setSpanForScope(scope, span ?? undefined);\n return callback(scope);\n });\n}\n","import type { Span } from '@opentelemetry/api';\nimport { isSpanContextValid, trace } from '@opentelemetry/api';\nimport type { Scope } from '@sentry/core';\nimport { getContextFromScope } from './contextData';\n\n/**\n * Returns the currently active span, or the active span of the given scope's context.\n *\n * Spans with an invalid span context (e.g. a malformed incoming trace/span id put on the context by\n * a propagator) are ignored, matching the OTel SDK tracer, so consumers start a fresh trace instead\n * of continuing a broken one.\n */\nexport function getActiveSpan(scope?: Scope): Span | undefined {\n const span = scope ? getSpanFromScope(scope) : trace.getActiveSpan();\n return span && isSpanContextValid(span.spanContext()) ? span : undefined;\n}\n\nfunction getSpanFromScope(scope: Scope): Span | undefined {\n const ctx = getContextFromScope(scope);\n // If no context can be picked from the scope, there is no span for it\n return ctx ? trace.getSpan(ctx) : undefined;\n}\n","import type { Context } from '@opentelemetry/api';\nimport type { Scope } from '@sentry/core';\nimport { getCurrentScope, getIsolationScope } from '@sentry/core';\nimport {\n SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY,\n SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY,\n SENTRY_FORK_SET_SCOPE_CONTEXT_KEY,\n} from '../constants';\nimport { getScopesFromContext, setContextOnScope, setScopesOnContext } from './contextData';\n\n/**\n * Merge Sentry scopes into an OpenTelemetry {@link Context} and apply trace-context adjustments\n * used by Sentry OpenTelemetry context manager(s).\n *\n * @param context - Context passed into `ContextManager.with`.\n * @param activeContext - Context that was active before entering `with` (e.g. `this.active()`), used\n * to restore the parent span when the incoming span is marked ignored for children.\n * @returns A new context ready for `super.with` / `AsyncLocalStorage.run`.\n */\nexport function buildContextWithSentryScopes(context: Context): Context {\n const currentScopes = getScopesFromContext(context);\n const currentScope = currentScopes?.scope || getCurrentScope();\n const currentIsolationScope = currentScopes?.isolationScope || getIsolationScope();\n\n const shouldForkIsolationScope = context.getValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY) === true;\n const scope = context.getValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY) as Scope | undefined;\n const isolationScope = context.getValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY) as Scope | undefined;\n\n const newCurrentScope = scope || currentScope.clone();\n const newIsolationScope =\n isolationScope || (shouldForkIsolationScope ? currentIsolationScope.clone() : currentIsolationScope);\n const scopes = { scope: newCurrentScope, isolationScope: newIsolationScope };\n\n const ctx1 = setScopesOnContext(context, scopes);\n\n const ctx2 = ctx1\n .deleteValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY)\n .deleteValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY)\n .deleteValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY);\n\n setContextOnScope(newCurrentScope, ctx2);\n\n return ctx2;\n}\n","/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * This implementation follows the behavior of OpenTelemetry’s `@opentelemetry/context-async-hooks`\n * package, combining logic that upstream splits across:\n * - https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts\n * - https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts\n * It is a single-class re-implementation for Sentry (not a verbatim copy of those files).\n */\n\nimport type { Context, ContextManager } from '@opentelemetry/api';\nimport { ROOT_CONTEXT } from '@opentelemetry/api';\nimport type { AsyncLocalStorage } from 'node:async_hooks';\nimport type { EventEmitter } from 'node:events';\nimport { SENTRY_SCOPES_CONTEXT_KEY } from './constants';\nimport { buildContextWithSentryScopes } from './utils/buildContextWithSentryScopes';\n\nexport type AsyncLocalStorageLookup = {\n asyncLocalStorage: AsyncLocalStorage<unknown>;\n /**\n * The OpenTelemetry context key under which the `{ scope, isolationScope }` object is stored, for\n * native threads that read scope out of the AsyncLocalStorage (e.g. `@sentry/node-native`). Omitted\n * for the pure AsyncLocalStorage strategy, whose store already is that object.\n */\n contextSymbol?: symbol;\n};\ntype ListenerFn = (...args: unknown[]) => unknown;\n\n/**\n * Per-event map from user listeners to context-bound listeners.\n */\ntype PatchMap = Record<string, WeakMap<ListenerFn, ListenerFn>>;\n\nconst ADD_LISTENER_METHODS = ['addListener', 'on', 'once', 'prependListener', 'prependOnceListener'] as const;\n\n/**\n * OpenTelemetry-compatible context manager using Node.js `AsyncLocalStorage`.\n */\nexport class SentryAsyncLocalStorageContextManager implements ContextManager {\n protected readonly _asyncLocalStorage: AsyncLocalStorage<Context>;\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n\n public constructor(asyncLocalStorage: AsyncLocalStorage<Context>) {\n this._asyncLocalStorage = asyncLocalStorage;\n }\n\n public active(): Context {\n return this._asyncLocalStorage.getStore() ?? ROOT_CONTEXT;\n }\n\n public with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n const ctx2 = buildContextWithSentryScopes(context);\n const cb = thisArg == null ? fn : fn.bind(thisArg);\n return this._asyncLocalStorage.run(ctx2, cb as never, ...args);\n }\n\n public enable(): this {\n return this;\n }\n\n public disable(): this {\n try {\n this._asyncLocalStorage.disable();\n } catch {\n // we don't care if something goes wrong here\n }\n return this;\n }\n\n public bind<T>(context: Context, target: T): T {\n if (isEventEmitter(target)) {\n return this._bindEventEmitter(context, target);\n }\n if (typeof target === 'function') {\n return this._bindFunction(context, target as unknown as ListenerFn) as T;\n }\n return target;\n }\n\n /**\n * Gets underlying AsyncLocalStorage and symbol to allow lookup of scope.\n * This is Sentry-specific.\n */\n public getAsyncLocalStorageLookup(): AsyncLocalStorageLookup {\n return {\n asyncLocalStorage: this._asyncLocalStorage,\n contextSymbol: SENTRY_SCOPES_CONTEXT_KEY,\n };\n }\n\n private _bindFunction(context: Context, target: ListenerFn): ListenerFn {\n const managerWith = this.with.bind(this);\n const contextWrapper = function (this: never, ...args: unknown[]) {\n return managerWith(context, () => target.apply(this, args));\n };\n Object.defineProperty(contextWrapper, 'length', {\n enumerable: false,\n configurable: true,\n writable: false,\n value: target.length,\n });\n return contextWrapper;\n }\n\n private _bindEventEmitter<T extends EventEmitter>(context: Context, ee: T): T {\n if (this._getPatchMap(ee) !== undefined) {\n return ee;\n }\n if (this._createPatchMap(ee) === undefined) {\n return ee;\n }\n\n for (const methodName of ADD_LISTENER_METHODS) {\n const original = getMethod(ee, methodName);\n if (!original) continue;\n trySetMethod(ee, methodName, this._patchAddListener(ee, original, context));\n }\n for (const methodName of ['removeListener', 'off'] as const) {\n const original = getMethod(ee, methodName);\n if (!original) continue;\n trySetMethod(ee, methodName, this._patchRemoveListener(ee, original));\n }\n const removeAllListeners = getMethod(ee, 'removeAllListeners');\n if (removeAllListeners) {\n trySetMethod(ee, 'removeAllListeners', this._patchRemoveAllListeners(ee, removeAllListeners));\n }\n return ee;\n }\n\n private _patchRemoveListener(ee: EventEmitter, original: (...args: unknown[]) => unknown) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event: string, listener: ListenerFn) {\n const events = contextManager._getPatchMap(ee)?.[event];\n if (events === undefined) {\n return original.call(this, event, listener);\n }\n const patchedListener = events.get(listener);\n return original.call(this, event, patchedListener || listener);\n };\n }\n\n private _patchRemoveAllListeners(ee: EventEmitter, original: (...args: unknown[]) => unknown) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event?: string) {\n const map = contextManager._getPatchMap(ee);\n if (map !== undefined) {\n if (arguments.length === 0) {\n // Best-effort reset: if the emitter was frozen after binding, this cannot replace the map\n // (and the map itself could not be cleared in place either). A stale map is harmless though —\n // `_patchAddListener` overwrites entries when a listener is re-added, and `_patchRemoveListener`\n // passing an already-unregistered wrapper to `original` is a no-op.\n contextManager._createPatchMap(ee);\n } else if (event !== undefined && map[event] !== undefined) {\n // oxlint-disable-next-line @typescript-eslint/no-dynamic-delete -- event-keyed listener map\n delete map[event];\n }\n }\n return original.apply(this, arguments);\n };\n }\n\n private _patchAddListener(ee: EventEmitter, original: (...args: unknown[]) => unknown, context: Context) {\n // oxlint-disable-next-line @typescript-eslint/no-this-alias\n const contextManager = this;\n return function (this: unknown, event: string, listener: ListenerFn) {\n if (contextManager._wrapped) {\n return original.call(this, event, listener);\n }\n const map = contextManager._getPatchMap(ee) ?? contextManager._createPatchMap(ee);\n if (map === undefined) {\n return original.call(this, event, listener);\n }\n let listeners = map[event];\n if (listeners === undefined) {\n listeners = new WeakMap();\n map[event] = listeners;\n }\n const patchedListener = contextManager.bind(context, listener);\n listeners.set(listener, patchedListener);\n\n contextManager._wrapped = true;\n try {\n return original.call(this, event, patchedListener);\n } finally {\n contextManager._wrapped = false;\n }\n };\n }\n\n /**\n * Attach a fresh patch map to the emitter. Returns `undefined` if the emitter does not accept the\n * property (e.g. it is frozen or sealed), in which case the emitter must not be patched at all —\n * without a patch map the remove-listener patches could not resolve their wrapped listeners.\n */\n private _createPatchMap(ee: EventEmitter): PatchMap | undefined {\n const map = Object.create(null) as PatchMap;\n try {\n (ee as unknown as Record<symbol, PatchMap>)[this._kOtListeners] = map;\n } catch {\n return undefined;\n }\n return this._getPatchMap(ee) === map ? map : undefined;\n }\n\n private _getPatchMap(ee: EventEmitter): PatchMap | undefined {\n return (ee as unknown as Record<symbol, PatchMap | undefined>)[this._kOtListeners];\n }\n}\n\n/**\n * Duck-typed `EventEmitter` check.\n *\n * We use this instead of `instanceof EventEmitter` so it also works in non-Node.js environments (e.g. vercel-edge)\n * and across realms. Both `on` and `emit` must be callable — checking only for the presence of an `on` property\n * would classify plain objects like `{ on: true }` as emitters and later try to call a non-function.\n */\nfunction isEventEmitter(target: unknown): target is EventEmitter {\n if (typeof target !== 'object' || !target) {\n return false;\n }\n const candidate = target as Partial<Record<'on' | 'emit', unknown>>;\n return typeof candidate.on === 'function' && typeof candidate.emit === 'function';\n}\n\n/**\n * Read a method off an emitter, ignoring inherited or own properties that are not callable.\n */\nfunction getMethod<T extends EventEmitter>(ee: T, methodName: keyof EventEmitter): ListenerFn | undefined {\n const value = (ee as unknown as Record<string, unknown>)[methodName as string];\n return typeof value === 'function' ? (value as ListenerFn) : undefined;\n}\n\n/**\n * Assign a patched method back onto the emitter. Emitters may be frozen or expose getter-only methods,\n * in which case we leave the original method in place instead of throwing.\n */\nfunction trySetMethod<T extends EventEmitter>(\n ee: T,\n methodName: keyof EventEmitter,\n patched: (...args: never[]) => unknown,\n): void {\n try {\n (ee as unknown as Record<string, unknown>)[methodName as string] = patched;\n } catch {\n // Nothing to do, the emitter keeps its unpatched method\n }\n}\n","import * as api from '@opentelemetry/api';\nimport type { Scope, TracingChannelBinding } from '@sentry/core';\nimport {\n getAsyncContextStrategy,\n _INTERNAL_safeMathRandom,\n generateTraceId,\n getDefaultCurrentScope,\n getDefaultIsolationScope,\n getMainCarrier,\n isContinuingTrace,\n setAsyncContextStrategy,\n} from '@sentry/core';\nimport {\n SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY,\n SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY,\n SENTRY_FORK_SET_SCOPE_CONTEXT_KEY,\n} from './constants';\nimport { withActiveSpan } from './trace';\nimport type { CurrentScopes } from './types';\nimport { getContextFromScope, getScopesFromContext } from './utils/contextData';\nimport { getActiveSpan } from './utils/getActiveSpan';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport type { AsyncLocalStorageLookup } from './asyncLocalStorageContextManager';\nimport { SentryAsyncLocalStorageContextManager } from './asyncLocalStorageContextManager';\n\n/**\n * Sets the async context strategy to use follow the OTEL context under the hood.\n * We handle forking a hub inside of our custom OTEL Context Manager (./otelContextManager.ts)\n */\nexport function setOpenTelemetryContextAsyncContextStrategy(): AsyncLocalStorageLookup {\n // Re-use the AsyncLocalStorage of an already-installed strategy, if any. Otherwise a repeated\n // setup would swap in a new store while integrations that captured the previous one (via\n // `getTracingChannelBinding().asyncLocalStorage`) keep reading the old one, breaking scope\n // propagation across async boundaries.\n const existingAsyncLocalStorage = getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.()\n ?.asyncLocalStorage as AsyncLocalStorage<api.Context> | undefined;\n\n const asyncLocalStorage = existingAsyncLocalStorage ?? new AsyncLocalStorage<api.Context>();\n\n function getScopes(): CurrentScopes {\n const ctx = api.context.active();\n const scopes = getScopesFromContext(ctx);\n\n if (scopes) {\n return scopes;\n }\n\n // fallback behavior:\n // if, for whatever reason, we can't find scopes on the context here, we have to fix this somehow\n return {\n scope: getDefaultCurrentScope(),\n isolationScope: getDefaultIsolationScope(),\n };\n }\n\n function withScope<T>(callback: (scope: Scope) => T): T {\n const ctx = api.context.active();\n\n // We depend on the otelContextManager to handle the context/hub\n // We set the `SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY` context value, which is picked up by\n // the OTEL context manager, which uses the presence of this key to determine if it should\n // fork the isolation scope, or not\n // as by default, we don't want to fork this, unless triggered explicitly by `withScope`\n return api.context.with(ctx, () => {\n return callback(getCurrentScope());\n });\n }\n\n function withSetScope<T>(scope: Scope, callback: (scope: Scope) => T): T {\n const ctx = getContextFromScope(scope) || api.context.active();\n\n // We depend on the otelContextManager to handle the context/hub\n // We set the `SENTRY_FORK_SET_SCOPE_CONTEXT_KEY` context value, which is picked up by\n // the OTEL context manager, which picks up this scope as the current scope\n return api.context.with(ctx.setValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY, scope), () => {\n return callback(scope);\n });\n }\n\n function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T {\n const ctx = api.context.active();\n\n // We depend on the otelContextManager to handle the context/hub\n // We set the `SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY` context value, which is picked up by\n // the OTEL context manager, which uses the presence of this key to determine if it should\n // fork the isolation scope, or not\n return api.context.with(ctx.setValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY, true), () => {\n // When forking an isolation scope, unless we are continuing an incoming\n // trace, we give the freshly forked scope its own trace. This way, new\n // root spans in an isolation scope will get separate traces. The\n // previous trace's `sampled` and `propagationSpanId` are dropped on\n // purpose. Carrying them over would apply the old trace's sampling\n // decision to the new one and propagate a span id from a different trace.\n const scope = getCurrentScope();\n if (!isContinuingTrace(scope.getPropagationContext())) {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: _INTERNAL_safeMathRandom(),\n });\n }\n return callback(getIsolationScope());\n });\n }\n\n function withSetIsolationScope<T>(isolationScope: Scope, callback: (isolationScope: Scope) => T): T {\n const ctx = api.context.active();\n\n // We depend on the otelContextManager to handle the context/hub\n // We set the `SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY` context value, which is picked up by\n // the OTEL context manager, which uses the presence of this key to determine if it should\n // fork the isolation scope, or not\n return api.context.with(ctx.setValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, isolationScope), () => {\n return callback(getIsolationScope());\n });\n }\n\n function getCurrentScope(): Scope {\n return getScopes().scope;\n }\n\n function getIsolationScope(): Scope {\n return getScopes().isolationScope;\n }\n\n function getTracingChannelBinding(): TracingChannelBinding {\n return {\n asyncLocalStorage,\n };\n }\n\n setAsyncContextStrategy({\n withScope,\n withSetScope,\n withSetIsolationScope,\n withIsolationScope,\n getCurrentScope,\n getIsolationScope,\n getActiveSpan,\n // The types here don't fully align, because our own `Span` type is narrower\n // than the OTEL one - but this is OK for here, as we now we'll only have OTEL spans passed around\n withActiveSpan: withActiveSpan,\n getTracingChannelBinding,\n });\n\n const ctxManager = new SentryAsyncLocalStorageContextManager(asyncLocalStorage);\n api.context.setGlobalContextManager(ctxManager);\n\n return ctxManager.getAsyncLocalStorageLookup();\n}\n","import type { SpanContext } from '@opentelemetry/api';\nimport { TraceFlags } from '@opentelemetry/api';\nimport { baggageHeaderToDynamicSamplingContext } from '@sentry/core';\nimport { SENTRY_TRACE_STATE_DSC, SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING } from '../constants';\n\n/**\n * OpenTelemetry only knows about SAMPLED or NONE decision,\n * but for us it is important to differentiate between unset and unsampled.\n *\n * Both of these are identified as `traceFlags === TracegFlags.NONE`,\n * but we additionally look at a special trace state to differentiate between them.\n */\nexport function getSamplingDecision(spanContext: SpanContext): boolean | undefined {\n const { traceFlags, traceState } = spanContext;\n\n const sampledNotRecording = traceState ? traceState.get(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING) === '1' : false;\n\n // If trace flag is `SAMPLED`, we interpret this as sampled\n // If it is `NONE`, it could mean either it was sampled to be not recorder, or that it was not sampled at all\n // For us this is an important difference, sow e look at the SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING\n // to identify which it is\n if (traceFlags === TraceFlags.SAMPLED) {\n return true;\n }\n\n if (sampledNotRecording) {\n return false;\n }\n\n // Fall back to DSC as a last resort, that may also contain `sampled`...\n const dscString = traceState ? traceState.get(SENTRY_TRACE_STATE_DSC) : undefined;\n const dsc = dscString ? baggageHeaderToDynamicSamplingContext(dscString) : undefined;\n\n if (dsc?.sampled === 'true') {\n return true;\n }\n if (dsc?.sampled === 'false') {\n return false;\n }\n\n return undefined;\n}\n","import type { Client } from '@sentry/core';\nimport { _INTERNAL_safeMathRandom, _INTERNAL_setSpanForScope, getDynamicSamplingContextFromSpan } from '@sentry/core';\nimport { SENTRY_TRACE_STATE_DSC } from './constants';\nimport { getSamplingDecision } from './utils/getSamplingDecision';\n\n/**\n * Registers the `prepareSpanScope` hook on the client.\n *\n * A remote parent is an incoming trace on the ambient OTel context, set by the propagator. It\n * cannot be used as a local parent span. The hook continues its trace through the propagation\n * context of a forked scope instead, so the span is created as a root span of the incoming trace,\n * like the OpenTelemetry SDK does for remote parents.\n */\nexport function registerPrepareSpanScope(client: Client): void {\n client.on('prepareSpanScope', spanScope => {\n const { scope, parentSpan } = spanScope;\n if (!parentSpan?.spanContext().isRemote) {\n return;\n }\n\n const { spanId, traceId, traceState } = parentSpan.spanContext();\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const sampleRand = typeof dsc.sample_rand === 'string' ? Number(dsc.sample_rand) : undefined;\n\n // Only freeze the DSC when the remote parent actually carried one (i.e. there was incoming\n // baggage). Otherwise leave it unset so it is derived dynamically from the span.\n const hasIncomingDsc = !!traceState?.get(SENTRY_TRACE_STATE_DSC);\n\n const forkedScope = scope.clone();\n forkedScope.setPropagationContext({\n traceId,\n parentSpanId: spanId,\n sampled: getSamplingDecision(parentSpan.spanContext()),\n dsc: hasIncomingDsc ? dsc : undefined,\n sampleRand: typeof sampleRand === 'number' && !Number.isNaN(sampleRand) ? sampleRand : _INTERNAL_safeMathRandom(),\n });\n _INTERNAL_setSpanForScope(forkedScope, undefined);\n\n spanScope.scope = forkedScope;\n spanScope.parentSpan = undefined;\n });\n}\n"],"names":["isTracingSuppressed","getActiveSpan"],"mappings":";;;;;;AAKO,MAAM,sBAAA,GAAyB,YAAA;AAC/B,MAAM,wCAAA,GAA2C,8BAAA;AAEjD,MAAM,yBAAA,GAA4B,iBAAiB,eAAe,CAAA;AAElE,MAAM,uCAAA,GAA0C,iBAAiB,6BAA6B,CAAA;AAE9F,MAAM,iCAAA,GAAoC,iBAAiB,uBAAuB,CAAA;AAElF,MAAM,2CAAA,GAA8C,iBAAiB,iCAAiC,CAAA;;ACR7G,MAAM,mBAAA,GAAsB,SAAA;AAMrB,SAAS,qBAAqB,OAAA,EAA6C;AAChF,EAAA,OAAO,OAAA,CAAQ,SAAS,yBAAyB,CAAA;AACnD;AAMO,SAAS,kBAAA,CAAmB,SAAkB,MAAA,EAAgC;AACnF,EAAA,OAAO,OAAA,CAAQ,QAAA,CAAS,yBAAA,EAA2B,MAAM,CAAA;AAC3D;AAYO,SAAS,iBAAA,CAAkB,OAAc,OAAA,EAAwB;AACtE,E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A;AAClB,IAAA,SAAA,CAAU,UAAA,GAAa,MAAA;AAAA,EACzB,CAAC,CAAA;AACH;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.0.0-alpha.
|
|
1
|
+
{"type":"module","version":"11.0.0-alpha.2","sideEffects":false}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncContextStrategy.d.ts","sourceRoot":"","sources":["../../src/asyncContextStrategy.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAGjF;;;GAGG;AACH,wBAAgB,2CAA2C,IAAI,uBAAuB,
|
|
1
|
+
{"version":3,"file":"asyncContextStrategy.d.ts","sourceRoot":"","sources":["../../src/asyncContextStrategy.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAGjF;;;GAGG;AACH,wBAAgB,2CAA2C,IAAI,uBAAuB,CAuHrF"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { SentryPropagator } from './propagator';
|
|
|
3
3
|
export { SentryTracerProvider } from './tracerProvider';
|
|
4
4
|
export { type AsyncLocalStorageLookup } from './asyncLocalStorageContextManager';
|
|
5
5
|
export { setOpenTelemetryContextAsyncContextStrategy } from './asyncContextStrategy';
|
|
6
|
+
export { registerPrepareSpanScope } from './prepareSpanScope';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,EAAE,2CAA2C,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,EAAE,2CAA2C,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Client } from '@sentry/core';
|
|
2
|
+
/**
|
|
3
|
+
* Registers the `prepareSpanScope` hook on the client.
|
|
4
|
+
*
|
|
5
|
+
* A remote parent is an incoming trace on the ambient OTel context, set by the propagator. It
|
|
6
|
+
* cannot be used as a local parent span. The hook continues its trace through the propagation
|
|
7
|
+
* context of a forked scope instead, so the span is created as a root span of the incoming trace,
|
|
8
|
+
* like the OpenTelemetry SDK does for remote parents.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerPrepareSpanScope(client: Client): void;
|
|
11
|
+
//# sourceMappingURL=prepareSpanScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareSpanScope.d.ts","sourceRoot":"","sources":["../../src/prepareSpanScope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA4B7D"}
|
package/build/types/trace.d.ts
CHANGED
|
@@ -1,37 +1,5 @@
|
|
|
1
1
|
import type { Span } from '@opentelemetry/api';
|
|
2
|
-
import type { Scope
|
|
3
|
-
/**
|
|
4
|
-
* Wraps a function with a transaction/span and finishes the span after the function is done.
|
|
5
|
-
* The created span is the active span and will be used as parent by other spans created inside the function
|
|
6
|
-
* and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.
|
|
7
|
-
*
|
|
8
|
-
* If you want to create a span that is not set as active, use {@link startInactiveSpan}.
|
|
9
|
-
*
|
|
10
|
-
* You'll always get a span passed to the callback,
|
|
11
|
-
* it may just be a non-recording span if the span is not sampled or if tracing is disabled.
|
|
12
|
-
*/
|
|
13
|
-
export declare function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T;
|
|
14
|
-
/**
|
|
15
|
-
* Similar to `Sentry.startSpan`. Wraps a function with a span, but does not finish the span
|
|
16
|
-
* after the function is done automatically. You'll have to call `span.end()` or the `finish` function passed to the callback manually.
|
|
17
|
-
*
|
|
18
|
-
* The created span is the active span and will be used as parent by other spans created inside the function
|
|
19
|
-
* and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.
|
|
20
|
-
*
|
|
21
|
-
* You'll always get a span passed to the callback,
|
|
22
|
-
* it may just be a non-recording span if the span is not sampled or if tracing is disabled.
|
|
23
|
-
*/
|
|
24
|
-
export declare function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a span. This span is not set as active, so will not get automatic instrumentation spans
|
|
27
|
-
* as children or be able to be accessed via `Sentry.getActiveSpan()`.
|
|
28
|
-
*
|
|
29
|
-
* If you want to create a span that is set as active, use {@link startSpan}.
|
|
30
|
-
*
|
|
31
|
-
* This function will always return a span,
|
|
32
|
-
* it may just be a non-recording span if the span is not sampled or if tracing is disabled.
|
|
33
|
-
*/
|
|
34
|
-
export declare function startInactiveSpan(options: StartSpanOptions): Span;
|
|
2
|
+
import type { Scope } from '@sentry/core';
|
|
35
3
|
/**
|
|
36
4
|
* Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be
|
|
37
5
|
* passed `null` to start an entirely new span tree.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,GAAG,CAAC,CASrF"}
|
package/build/types/tracer.d.ts
CHANGED
|
@@ -6,8 +6,13 @@ export declare class SentryTracer implements Tracer {
|
|
|
6
6
|
startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, fn: F): ReturnType<F>;
|
|
7
7
|
startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, options: SpanOptions, fn: F): ReturnType<F>;
|
|
8
8
|
startActiveSpan<F extends (span: OpenTelemetrySpan) => unknown>(name: string, options: SpanOptions, ctx: Context, fn: F): ReturnType<F>;
|
|
9
|
+
/**
|
|
10
|
+
* Whether a span started with these arguments gets a parent. Mirrors the parent lookup in `startSpan`
|
|
11
|
+
* plus core's fallback to the scope's active span, which is what parents the span on runtimes without an
|
|
12
|
+
* OTel context manager.
|
|
13
|
+
*/
|
|
14
|
+
private _hasParentSpan;
|
|
9
15
|
private _startSentrySpan;
|
|
10
|
-
private _startRootSpanWithRemoteParent;
|
|
11
16
|
private _createNonRecordingSpan;
|
|
12
17
|
}
|
|
13
18
|
//# sourceMappingURL=tracer.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAuBlG,qBAAa,YAAa,YAAW,MAAM;IACzC,kBAAkB;IACX,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAoB1F;IAED,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,CAAC;IACpG,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,CAAC;IACV,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,CAAC;IAuDjB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,gBAAgB;IAkCxB,OAAO,CAAC,uBAAuB;CAgBhC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { Span } from '@opentelemetry/api';
|
|
2
2
|
import type { Scope } from '@sentry/core';
|
|
3
3
|
/**
|
|
4
|
-
* Returns the currently active span.
|
|
4
|
+
* Returns the currently active span, or the active span of the given scope's context.
|
|
5
|
+
*
|
|
6
|
+
* Spans with an invalid span context (e.g. a malformed incoming trace/span id put on the context by
|
|
7
|
+
* a propagator) are ignored, matching the OTel SDK tracer, so consumers start a fresh trace instead
|
|
8
|
+
* of continuing a broken one.
|
|
5
9
|
*/
|
|
6
10
|
export declare function getActiveSpan(scope?: Scope): Span | undefined;
|
|
7
11
|
//# sourceMappingURL=getActiveSpan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getActiveSpan.d.ts","sourceRoot":"","sources":["../../../src/utils/getActiveSpan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C
|
|
1
|
+
{"version":3,"file":"getActiveSpan.d.ts","sourceRoot":"","sources":["../../../src/utils/getActiveSpan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,CAG7D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/opentelemetry",
|
|
3
|
-
"version": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.2",
|
|
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",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@sentry/conventions": "^0.
|
|
31
|
-
"@sentry/core": "11.0.0-alpha.
|
|
30
|
+
"@sentry/conventions": "^0.20.0",
|
|
31
|
+
"@sentry/core": "11.0.0-alpha.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@opentelemetry/api": "^1.9.0"
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"clean": "rimraf build coverage sentry-opentelemetry-*.tgz",
|
|
50
50
|
"lint:fix": "oxlint . --fix --type-aware",
|
|
51
51
|
"lint": "oxlint . --type-aware",
|
|
52
|
+
"lint:types": "oxlint src --type-aware --type-check",
|
|
52
53
|
"lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module",
|
|
53
54
|
"test": "yarn test:unit",
|
|
54
55
|
"test:unit": "vitest run",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { DynamicSamplingContext } from '@sentry/core';
|
|
2
|
-
/**
|
|
3
|
-
* Reconcile a freshly-derived DSC's `sampled` flag with the OTel sampling decision.
|
|
4
|
-
*
|
|
5
|
-
* Only applies to a DSC that core generated from the span's (binary) trace flags — never to a frozen
|
|
6
|
-
* incoming DSC from the trace state, which the caller leaves untouched per the propagation spec.
|
|
7
|
-
* Trace flags cannot tell a *deferred* decision (an incoming remote span whose decision lives in the
|
|
8
|
-
* trace state) apart from a definitive *unsampled* one — both read as `traceFlags: NONE`.
|
|
9
|
-
* `getSamplingDecision` resolves this via the OTel trace state, so we let it win here: drop `sampled`
|
|
10
|
-
* when the decision is deferred (`undefined`), and — matching the OTel SDK, whose unsampled spans are
|
|
11
|
-
* nameless non-recording spans — drop the transaction name when the trace is definitively unsampled.
|
|
12
|
-
*/
|
|
13
|
-
export declare function reconcileDscSampled(dsc: Partial<DynamicSamplingContext>, sampled: boolean | undefined): Partial<DynamicSamplingContext>;
|
|
14
|
-
//# sourceMappingURL=reconcileDscSampled.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reconcileDscSampled.d.ts","sourceRoot":"","sources":["../../../src/utils/reconcileDscSampled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,OAAO,CAAC,sBAAsB,CAAC,EACpC,OAAO,EAAE,OAAO,GAAG,SAAS,GAC3B,OAAO,CAAC,sBAAsB,CAAC,CAajC"}
|