@sentry/opentelemetry 7.105.0 → 8.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/README.md +8 -14
- package/cjs/asyncContextStrategy.js +87 -19
- package/cjs/asyncContextStrategy.js.map +1 -1
- package/cjs/constants.js +16 -4
- package/cjs/constants.js.map +1 -1
- package/cjs/contextManager.js +42 -15
- package/cjs/contextManager.js.map +1 -1
- package/cjs/custom/client.js +0 -28
- package/cjs/custom/client.js.map +1 -1
- package/cjs/custom/getCurrentHub.js +106 -0
- package/cjs/custom/getCurrentHub.js.map +1 -0
- package/cjs/custom/hub.js +3 -136
- package/cjs/custom/hub.js.map +1 -1
- package/cjs/custom/transaction.js +3 -32
- package/cjs/custom/transaction.js.map +1 -1
- package/cjs/index.js +9 -9
- package/cjs/index.js.map +1 -1
- package/cjs/propagator.js +125 -40
- package/cjs/propagator.js.map +1 -1
- package/cjs/sampler.js +7 -6
- package/cjs/sampler.js.map +1 -1
- package/cjs/semanticAttributes.js +0 -9
- package/cjs/semanticAttributes.js.map +1 -1
- package/cjs/setupEventContextTrace.js +12 -7
- package/cjs/setupEventContextTrace.js.map +1 -1
- package/cjs/spanExporter.js +62 -58
- package/cjs/spanExporter.js.map +1 -1
- package/cjs/spanProcessor.js +16 -18
- package/cjs/spanProcessor.js.map +1 -1
- package/cjs/trace.js +120 -23
- package/cjs/trace.js.map +1 -1
- package/cjs/utils/addOriginToSpan.js +2 -2
- package/cjs/utils/addOriginToSpan.js.map +1 -1
- package/cjs/utils/contextData.js +35 -15
- package/cjs/utils/contextData.js.map +1 -1
- package/cjs/utils/dynamicSamplingContext.js +64 -0
- package/cjs/utils/dynamicSamplingContext.js.map +1 -0
- package/cjs/utils/mapStatus.js +5 -4
- package/cjs/utils/mapStatus.js.map +1 -1
- package/cjs/utils/setupCheck.js +17 -0
- package/cjs/utils/setupCheck.js.map +1 -0
- package/cjs/utils/spanData.js +23 -23
- package/cjs/utils/spanData.js.map +1 -1
- package/esm/asyncContextStrategy.js +89 -18
- package/esm/asyncContextStrategy.js.map +1 -1
- package/esm/constants.js +11 -4
- package/esm/constants.js.map +1 -1
- package/esm/contextManager.js +41 -17
- package/esm/contextManager.js.map +1 -1
- package/esm/custom/client.js +0 -28
- package/esm/custom/client.js.map +1 -1
- package/esm/custom/getCurrentHub.js +101 -0
- package/esm/custom/getCurrentHub.js.map +1 -0
- package/esm/custom/hub.js +4 -133
- package/esm/custom/hub.js.map +1 -1
- package/esm/custom/transaction.js +4 -32
- package/esm/custom/transaction.js.map +1 -1
- package/esm/index.js +7 -5
- package/esm/index.js.map +1 -1
- package/esm/propagator.js +128 -45
- package/esm/propagator.js.map +1 -1
- package/esm/sampler.js +7 -6
- package/esm/sampler.js.map +1 -1
- package/esm/semanticAttributes.js +0 -9
- package/esm/semanticAttributes.js.map +1 -1
- package/esm/setupEventContextTrace.js +14 -9
- package/esm/setupEventContextTrace.js.map +1 -1
- package/esm/spanExporter.js +63 -59
- package/esm/spanExporter.js.map +1 -1
- package/esm/spanProcessor.js +12 -14
- package/esm/spanProcessor.js.map +1 -1
- package/esm/trace.js +122 -26
- package/esm/trace.js.map +1 -1
- package/esm/utils/addOriginToSpan.js +2 -2
- package/esm/utils/addOriginToSpan.js.map +1 -1
- package/esm/utils/contextData.js +33 -15
- package/esm/utils/contextData.js.map +1 -1
- package/esm/utils/dynamicSamplingContext.js +59 -0
- package/esm/utils/dynamicSamplingContext.js.map +1 -0
- package/esm/utils/mapStatus.js +5 -4
- package/esm/utils/mapStatus.js.map +1 -1
- package/esm/utils/setupCheck.js +14 -0
- package/esm/utils/setupCheck.js.map +1 -0
- package/esm/utils/spanData.js +22 -20
- package/esm/utils/spanData.js.map +1 -1
- package/package.json +5 -5
- package/types/asyncContextStrategy.d.ts.map +1 -1
- package/types/constants.d.ts +6 -2
- package/types/constants.d.ts.map +1 -1
- package/types/contextManager.d.ts +1 -1
- package/types/contextManager.d.ts.map +1 -1
- package/types/custom/client.d.ts.map +1 -1
- package/types/custom/getCurrentHub.d.ts +7 -0
- package/types/custom/getCurrentHub.d.ts.map +1 -0
- package/types/custom/hub.d.ts +2 -33
- package/types/custom/hub.d.ts.map +1 -1
- package/types/custom/transaction.d.ts +1 -10
- package/types/custom/transaction.d.ts.map +1 -1
- package/types/index.d.ts +7 -5
- package/types/index.d.ts.map +1 -1
- package/types/propagator.d.ts +11 -2
- package/types/propagator.d.ts.map +1 -1
- package/types/sampler.d.ts.map +1 -1
- package/types/semanticAttributes.d.ts +0 -9
- package/types/semanticAttributes.d.ts.map +1 -1
- package/types/setupEventContextTrace.d.ts.map +1 -1
- package/types/spanExporter.d.ts.map +1 -1
- package/types/spanProcessor.d.ts +1 -5
- package/types/spanProcessor.d.ts.map +1 -1
- package/types/trace.d.ts +14 -3
- package/types/trace.d.ts.map +1 -1
- package/types/types.d.ts +7 -12
- package/types/types.d.ts.map +1 -1
- package/types/utils/addOriginToSpan.d.ts.map +1 -1
- package/types/utils/contextData.d.ts +21 -10
- package/types/utils/contextData.d.ts.map +1 -1
- package/types/utils/dynamicSamplingContext.d.ts +11 -0
- package/types/utils/dynamicSamplingContext.d.ts.map +1 -0
- package/types/utils/mapStatus.d.ts +2 -2
- package/types/utils/mapStatus.d.ts.map +1 -1
- package/types/utils/setupCheck.d.ts +9 -0
- package/types/utils/setupCheck.d.ts.map +1 -0
- package/types/utils/spanData.d.ts +14 -8
- package/types/utils/spanData.d.ts.map +1 -1
- package/types-ts3.8/constants.d.ts +6 -2
- package/types-ts3.8/contextManager.d.ts +1 -1
- package/types-ts3.8/custom/getCurrentHub.d.ts +7 -0
- package/types-ts3.8/custom/hub.d.ts +2 -33
- package/types-ts3.8/custom/transaction.d.ts +1 -10
- package/types-ts3.8/index.d.ts +7 -5
- package/types-ts3.8/propagator.d.ts +11 -2
- package/types-ts3.8/semanticAttributes.d.ts +0 -9
- package/types-ts3.8/spanProcessor.d.ts +1 -5
- package/types-ts3.8/trace.d.ts +14 -3
- package/types-ts3.8/types.d.ts +7 -12
- package/types-ts3.8/utils/contextData.d.ts +21 -10
- package/types-ts3.8/utils/dynamicSamplingContext.d.ts +11 -0
- package/types-ts3.8/utils/mapStatus.d.ts +2 -2
- package/types-ts3.8/utils/setupCheck.d.ts +9 -0
- package/types-ts3.8/utils/spanData.d.ts +14 -8
- package/cjs/custom/scope.js +0 -202
- package/cjs/custom/scope.js.map +0 -1
- package/esm/custom/scope.js +0 -200
- package/esm/custom/scope.js.map +0 -1
- package/types/custom/scope.d.ts +0 -42
- package/types/custom/scope.d.ts.map +0 -1
- package/types-ts3.8/custom/scope.d.ts +0 -42
package/esm/trace.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sources":["../../src/trace.ts"],"sourcesContent":["import type { Span, Tracer } from '@opentelemetry/api';\nimport { context } from '@opentelemetry/api';\nimport { SpanStatusCode, trace } from '@opentelemetry/api';\nimport { suppressTracing } from '@opentelemetry/core';\nimport { SDK_VERSION, handleCallbackErrors } from '@sentry/core';\nimport type { Client } from '@sentry/types';\n\nimport { getClient } from './custom/hub';\nimport { InternalSentrySemanticAttributes } from './semanticAttributes';\nimport type { OpenTelemetryClient, OpenTelemetrySpanContext } from './types';\nimport { setSpanMetadata } from './utils/spanData';\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.getSpan()`, 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 * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.\n */\nexport function startSpan<T>(spanContext: OpenTelemetrySpanContext, callback: (span: Span) => T): T {\n const tracer = getTracer();\n\n const { name } = spanContext;\n\n const activeCtx = context.active();\n const shouldSkipSpan = spanContext.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;\n\n return tracer.startActiveSpan(name, spanContext, ctx, span => {\n _applySentryAttributesToSpan(span, spanContext);\n\n return handleCallbackErrors(\n () => callback(span),\n () => {\n span.setStatus({ code: SpanStatusCode.ERROR });\n },\n () => span.end(),\n );\n });\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()` 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 * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.\n */\nexport function startSpanManual<T>(spanContext: OpenTelemetrySpanContext, callback: (span: Span) => T): T {\n const tracer = getTracer();\n\n const { name } = spanContext;\n\n const activeCtx = context.active();\n const shouldSkipSpan = spanContext.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;\n\n return tracer.startActiveSpan(name, spanContext, ctx, span => {\n _applySentryAttributesToSpan(span, spanContext);\n\n return handleCallbackErrors(\n () => callback(span),\n () => {\n span.setStatus({ code: SpanStatusCode.ERROR });\n },\n );\n });\n}\n\n/**\n * @deprecated Use {@link startSpan} instead.\n */\nexport const startActiveSpan = startSpan;\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.getSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * Note that if you have not enabled tracing extensions via `addTracingExtensions`\n * or you didn't set `tracesSampleRate` or `tracesSampler`, this function will not generate spans\n * and the `span` returned from the callback will be undefined.\n */\nexport function startInactiveSpan(spanContext: OpenTelemetrySpanContext): Span {\n const tracer = getTracer();\n\n const { name } = spanContext;\n\n const activeCtx = context.active();\n const shouldSkipSpan = spanContext.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;\n\n const span = tracer.startSpan(name, spanContext, ctx);\n\n _applySentryAttributesToSpan(span, spanContext);\n\n return span;\n}\n\nfunction getTracer(): Tracer {\n const client = getClient<Client & OpenTelemetryClient>();\n return (client && client.tracer) || trace.getTracer('@sentry/opentelemetry', SDK_VERSION);\n}\n\nfunction _applySentryAttributesToSpan(span: Span, spanContext: OpenTelemetrySpanContext): void {\n const { origin, op, source, metadata } = spanContext;\n\n if (origin) {\n span.setAttribute(InternalSentrySemanticAttributes.ORIGIN, origin);\n }\n\n if (op) {\n span.setAttribute(InternalSentrySemanticAttributes.OP, op);\n }\n\n if (source) {\n span.setAttribute(InternalSentrySemanticAttributes.SOURCE, source);\n }\n\n if (metadata) {\n setSpanMetadata(span, metadata);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAI,WAAW,EAA4B,QAAQ,EAAwB;AACpG,EAAE,MAAM,MAAA,GAAS,SAAS,EAAE,CAAA;AAC5B;AACA,EAAE,MAAM,EAAE,IAAK,EAAA,GAAI,WAAW,CAAA;AAC9B;AACA,EAAE,MAAM,SAAU,GAAE,OAAO,CAAC,MAAM,EAAE,CAAA;AACpC,EAAE,MAAM,cAAA,GAAiB,WAAW,CAAC,YAAA,IAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AAC9E,EAAE,MAAM,GAAI,GAAE,cAAe,GAAE,eAAe,CAAC,SAAS,CAAE,GAAE,SAAS,CAAA;AACrE;AACA,EAAE,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAA,IAAQ;AAChE,IAAI,4BAA4B,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;AACnD;AACA,IAAI,OAAO,oBAAoB;AAC/B,MAAM,MAAM,QAAQ,CAAC,IAAI,CAAC;AAC1B,MAAM,MAAM;AACZ,QAAQ,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,KAAM,EAAC,CA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AAC,CAAA;AACnC,GAAE;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"trace.js","sources":["../../src/trace.ts"],"sourcesContent":["import type { Context, Span, SpanContext, SpanOptions, Tracer } from '@opentelemetry/api';\nimport { TraceFlags } from '@opentelemetry/api';\nimport { context } from '@opentelemetry/api';\nimport { SpanStatusCode, trace } from '@opentelemetry/api';\nimport { TraceState, suppressTracing } from '@opentelemetry/core';\nimport {\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getClient,\n getCurrentScope,\n handleCallbackErrors,\n} from '@sentry/core';\nimport type { Client, Scope } from '@sentry/types';\nimport { dynamicSamplingContextToSentryBaggageHeader } from '@sentry/utils';\nimport { SENTRY_TRACE_STATE_DSC } from './constants';\n\nimport type { OpenTelemetryClient, OpenTelemetrySpanContext } from './types';\nimport { getContextFromScope } from './utils/contextData';\nimport { getDynamicSamplingContextFromSpan } from './utils/dynamicSamplingContext';\nimport { getRootSpan } from './utils/getActiveSpan';\nimport { setSpanMetadata } from './utils/spanData';\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.getSpan()`, 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 * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.\n */\nexport function startSpan<T>(options: OpenTelemetrySpanContext, callback: (span: Span) => T): T {\n const tracer = getTracer();\n\n const { name } = options;\n\n const activeCtx = getContext(options.scope, options.forceTransaction);\n const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;\n\n const spanContext = getSpanContext(options);\n\n return tracer.startActiveSpan(name, spanContext, ctx, span => {\n _applySentryAttributesToSpan(span, options);\n\n return handleCallbackErrors(\n () => callback(span),\n () => {\n span.setStatus({ code: SpanStatusCode.ERROR });\n },\n () => span.end(),\n );\n });\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()` 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 * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.\n */\nexport function startSpanManual<T>(options: OpenTelemetrySpanContext, callback: (span: Span) => T): T {\n const tracer = getTracer();\n\n const { name } = options;\n\n const activeCtx = getContext(options.scope, options.forceTransaction);\n const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;\n\n const spanContext = getSpanContext(options);\n\n return tracer.startActiveSpan(name, spanContext, ctx, span => {\n _applySentryAttributesToSpan(span, options);\n\n return handleCallbackErrors(\n () => callback(span),\n () => {\n span.setStatus({ code: SpanStatusCode.ERROR });\n },\n );\n });\n}\n\n/**\n * @deprecated Use {@link startSpan} instead.\n */\nexport const startActiveSpan = startSpan;\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.getSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * Note that if you have not enabled tracing extensions via `addTracingExtensions`\n * or you didn't set `tracesSampleRate` or `tracesSampler`, this function will not generate spans\n * and the `span` returned from the callback will be undefined.\n */\nexport function startInactiveSpan(options: OpenTelemetrySpanContext): Span {\n const tracer = getTracer();\n\n const { name } = options;\n\n const activeCtx = getContext(options.scope, options.forceTransaction);\n const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;\n\n const spanContext = getSpanContext(options);\n\n const span = tracer.startSpan(name, spanContext, ctx);\n\n _applySentryAttributesToSpan(span, options);\n\n return span;\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 not be attached to a parent span.\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 const client = getClient<Client & OpenTelemetryClient>();\n return (client && client.tracer) || trace.getTracer('@sentry/opentelemetry', SDK_VERSION);\n}\n\nfunction _applySentryAttributesToSpan(span: Span, options: OpenTelemetrySpanContext): void {\n // eslint-disable-next-line deprecation/deprecation\n const { origin, op, source, metadata } = options;\n\n if (origin) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);\n }\n\n if (op) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, op);\n }\n\n if (source) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n }\n\n if (metadata) {\n setSpanMetadata(span, metadata);\n }\n}\n\nfunction getSpanContext(options: OpenTelemetrySpanContext): SpanOptions {\n const { startTime, attributes, kind } = options;\n\n // OTEL expects timestamps in ms, not seconds\n const fixedStartTime = typeof startTime === 'number' ? ensureTimestampInMilliseconds(startTime) : startTime;\n\n return {\n attributes,\n kind,\n startTime: fixedStartTime,\n };\n}\n\nfunction ensureTimestampInMilliseconds(timestamp: number): number {\n const isMs = timestamp < 9999999999;\n return isMs ? timestamp * 1000 : timestamp;\n}\n\nfunction getContext(scope: Scope | undefined, forceTransaction: boolean | undefined): Context {\n const ctx = getContextForScope(scope);\n\n if (!forceTransaction) {\n return ctx;\n }\n\n // Else we need to \"fix\" the context to have no parent span\n const parentSpan = trace.getSpan(ctx);\n\n // If there is no parent span, all good, nothing to do!\n if (!parentSpan) {\n return ctx;\n }\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, traceFlags } = parentSpan.spanContext();\n // eslint-disable-next-line no-bitwise\n const sampled = Boolean(traceFlags & TraceFlags.SAMPLED);\n\n const rootSpan = getRootSpan(parentSpan);\n const dsc = getDynamicSamplingContextFromSpan(rootSpan);\n const dscString = dynamicSamplingContextToSentryBaggageHeader(dsc);\n\n const traceState = dscString ? new TraceState().set(SENTRY_TRACE_STATE_DSC, dscString) : undefined;\n\n const spanContext: 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, spanContext);\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"],"names":[],"mappings":";;;;;;;;;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAI,OAAO,EAA4B,QAAQ,EAAwB;AAChG,EAAE,MAAM,MAAA,GAAS,SAAS,EAAE,CAAA;AAC5B;AACA,EAAE,MAAM,EAAE,IAAK,EAAA,GAAI,OAAO,CAAA;AAC1B;AACA,EAAE,MAAM,SAAA,GAAY,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;AACvE,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,YAAA,IAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AAC1E,EAAE,MAAM,GAAI,GAAE,cAAe,GAAE,eAA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AC,GAAG,CAAC,sBAAsB,EAAE,SAAS,CAAA,GAAI,SAAS,CAAA;AACpG;AACA,EAAE,MAAM,WAAW,GAAgB;AACnC,IAAI,OAAO;AACX,IAAI,MAAM;AACV,IAAI,QAAQ,EAAE,IAAI;AAClB,IAAI,UAAU,EAAE,OAAA,GAAU,UAAU,CAAC,OAAQ,GAAE,UAAU,CAAC,IAAI;AAC9D,IAAI,UAAU;AACd,GAAG,CAAA;AACH;AACA,EAAE,MAAM,kBAAmB,GAAE,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;AAC9E;AACA,EAAE,OAAO,kBAAkB,CAAA;AAC3B,CAAA;AACA;AACA,SAAS,kBAAkB,CAAC,KAAK,EAAmB;AACpD,EAAE,IAAI,KAAK,EAAE;AACb,IAAI,MAAM,GAAI,GAAE,mBAAmB,CAAC,KAAK,CAAC,CAAA;AAC1C,IAAI,IAAI,GAAG,EAAE;AACb,MAAM,OAAO,GAAG,CAAA;AAChB,KAAI;AACJ,GAAE;AACF;AACA,EAAE,OAAO,OAAO,CAAC,MAAM,EAAE,CAAA;AACzB;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
2
2
|
|
|
3
3
|
/** Adds an origin to an OTEL Span. */
|
|
4
4
|
function addOriginToSpan(span, origin) {
|
|
5
|
-
span.setAttribute(
|
|
5
|
+
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export { addOriginToSpan };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addOriginToSpan.js","sources":["../../../src/utils/addOriginToSpan.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport
|
|
1
|
+
{"version":3,"file":"addOriginToSpan.js","sources":["../../../src/utils/addOriginToSpan.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';\nimport type { SpanOrigin } from '@sentry/types';\n\n/** Adds an origin to an OTEL Span. */\nexport function addOriginToSpan(span: Span, origin: SpanOrigin): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);\n}\n"],"names":[],"mappings":";;AAIA;AACO,SAAS,eAAe,CAAC,IAAI,EAAQ,MAAM,EAAoB;AACtE,EAAE,IAAI,CAAC,YAAY,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAA;AAC7D;;;;"}
|
package/esm/utils/contextData.js
CHANGED
|
@@ -1,36 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SENTRY_SCOPES_CONTEXT_KEY, SENTRY_HUB_CONTEXT_KEY } from '../constants.js';
|
|
2
|
+
|
|
3
|
+
const SCOPE_CONTEXT_MAP = new WeakMap();
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
|
-
* Try to get the
|
|
5
|
-
* This requires
|
|
6
|
+
* Try to get the Hub from the given OTEL context.
|
|
7
|
+
* This requires a Context Manager that was wrapped with getWrappedContextManager.
|
|
6
8
|
*/
|
|
7
|
-
function
|
|
8
|
-
return context.getValue(
|
|
9
|
+
function getHubFromContext(context) {
|
|
10
|
+
return context.getValue(SENTRY_HUB_CONTEXT_KEY) ;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
* Set a
|
|
14
|
+
* Set a Hub on an OTEL context..
|
|
13
15
|
* This will return a forked context with the Propagation Context set.
|
|
14
16
|
*/
|
|
15
|
-
function
|
|
16
|
-
return context.setValue(
|
|
17
|
+
function setHubOnContext(context, hub) {
|
|
18
|
+
return context.setValue(SENTRY_HUB_CONTEXT_KEY, hub);
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
|
-
* Try to get the
|
|
22
|
+
* Try to get the current scopes from the given OTEL context.
|
|
21
23
|
* This requires a Context Manager that was wrapped with getWrappedContextManager.
|
|
22
24
|
*/
|
|
23
|
-
function
|
|
24
|
-
return context.getValue(
|
|
25
|
+
function getScopesFromContext(context) {
|
|
26
|
+
return context.getValue(SENTRY_SCOPES_CONTEXT_KEY) ;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
|
-
* Set
|
|
30
|
+
* Set the current scopes on an OTEL context.
|
|
29
31
|
* This will return a forked context with the Propagation Context set.
|
|
30
32
|
*/
|
|
31
|
-
function
|
|
32
|
-
return context.setValue(
|
|
33
|
+
function setScopesOnContext(context, scopes) {
|
|
34
|
+
return context.setValue(SENTRY_SCOPES_CONTEXT_KEY, scopes);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set the context on the scope so we can later look it up.
|
|
39
|
+
* We need this to get the context from the scope in the `trace` functions.
|
|
40
|
+
*/
|
|
41
|
+
function setContextOnScope(scope, context) {
|
|
42
|
+
SCOPE_CONTEXT_MAP.set(scope, context);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get the context related to a scope.
|
|
47
|
+
* TODO v8: Use this for the `trace` functions.
|
|
48
|
+
* */
|
|
49
|
+
function getContextFromScope(scope) {
|
|
50
|
+
return SCOPE_CONTEXT_MAP.get(scope);
|
|
33
51
|
}
|
|
34
52
|
|
|
35
|
-
export { getHubFromContext,
|
|
53
|
+
export { getContextFromScope, getHubFromContext, getScopesFromContext, setContextOnScope, setHubOnContext, setScopesOnContext };
|
|
36
54
|
//# sourceMappingURL=contextData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextData.js","sources":["../../../src/utils/contextData.ts"],"sourcesContent":["import type { Context } from '@opentelemetry/api';\nimport type { Hub,
|
|
1
|
+
{"version":3,"file":"contextData.js","sources":["../../../src/utils/contextData.ts"],"sourcesContent":["import type { Context } from '@opentelemetry/api';\nimport type { Hub, Scope } from '@sentry/types';\n\nimport { SENTRY_HUB_CONTEXT_KEY, SENTRY_SCOPES_CONTEXT_KEY } from '../constants';\nimport type { CurrentScopes } from '../types';\n\nconst SCOPE_CONTEXT_MAP = new WeakMap<Scope, Context>();\n\n/**\n * Try to get the Hub from the given OTEL context.\n * This requires a Context Manager that was wrapped with getWrappedContextManager.\n */\nexport function getHubFromContext(context: Context): Hub | undefined {\n return context.getValue(SENTRY_HUB_CONTEXT_KEY) as Hub | undefined;\n}\n\n/**\n * Set a Hub on an OTEL context..\n * This will return a forked context with the Propagation Context set.\n */\nexport function setHubOnContext(context: Context, hub: Hub): Context {\n return context.setValue(SENTRY_HUB_CONTEXT_KEY, hub);\n}\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 */\nexport function setContextOnScope(scope: Scope, context: Context): void {\n SCOPE_CONTEXT_MAP.set(scope, context);\n}\n\n/**\n * Get the context related to a scope.\n * TODO v8: Use this for the `trace` functions.\n * */\nexport function getContextFromScope(scope: Scope): Context | undefined {\n return SCOPE_CONTEXT_MAP.get(scope);\n}\n"],"names":[],"mappings":";;AAMA,MAAM,iBAAkB,GAAE,IAAI,OAAO,EAAkB,CAAA;AACvD;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,OAAO,EAA4B;AACrE,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAE,EAAA;AAClD,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,OAAO,EAAW,GAAG,EAAgB;AACrE,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA;AACtD,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,OAAO,EAAsC;AAClF,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAE,EAAA;AACrD,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,OAAO,EAAW,MAAM,EAA0B;AACrF,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAA;AAC5D,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,KAAK,EAAS,OAAO,EAAiB;AACxE,EAAE,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AACvC,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,KAAK,EAA8B;AACvE,EAAE,OAAO,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AACrC;;;;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { _optionalChain } from '@sentry/utils';
|
|
2
|
+
import { TraceFlags } from '@opentelemetry/api';
|
|
3
|
+
import { getClient, getDynamicSamplingContextFromClient, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
|
|
4
|
+
import { baggageHeaderToDynamicSamplingContext } from '@sentry/utils';
|
|
5
|
+
import { SENTRY_TRACE_STATE_DSC } from '../constants.js';
|
|
6
|
+
import { spanHasAttributes, spanHasName } from './spanTypes.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a dynamic sampling context from a span (and client and scope)
|
|
10
|
+
*
|
|
11
|
+
* @param span the span from which a few values like the root span name and sample rate are extracted.
|
|
12
|
+
*
|
|
13
|
+
* @returns a dynamic sampling context
|
|
14
|
+
*/
|
|
15
|
+
function getDynamicSamplingContextFromSpan(span) {
|
|
16
|
+
const client = getClient();
|
|
17
|
+
if (!client) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const traceState = span.spanContext().traceState;
|
|
22
|
+
const traceStateDsc = _optionalChain([traceState, 'optionalAccess', _ => _.get, 'call', _2 => _2(SENTRY_TRACE_STATE_DSC)]);
|
|
23
|
+
|
|
24
|
+
// If the span has a DSC, we want it to take precedence
|
|
25
|
+
const dscOnSpan = traceStateDsc ? baggageHeaderToDynamicSamplingContext(traceStateDsc) : undefined;
|
|
26
|
+
|
|
27
|
+
if (dscOnSpan) {
|
|
28
|
+
return dscOnSpan;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);
|
|
32
|
+
|
|
33
|
+
const attributes = spanHasAttributes(span) ? span.attributes : {};
|
|
34
|
+
|
|
35
|
+
const sampleRate = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];
|
|
36
|
+
if (sampleRate != null) {
|
|
37
|
+
dsc.sample_rate = `${sampleRate}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// We don't want to have a transaction name in the DSC if the source is "url" because URLs might contain PII
|
|
41
|
+
const source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
|
|
42
|
+
const name = spanHasName(span) ? span.name : '';
|
|
43
|
+
|
|
44
|
+
if (source !== 'url' && name) {
|
|
45
|
+
dsc.transaction = name;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// TODO: Once we aligned span types, use spanIsSampled() from core instead
|
|
49
|
+
// eslint-disable-next-line no-bitwise
|
|
50
|
+
const sampled = Boolean(span.spanContext().traceFlags & TraceFlags.SAMPLED);
|
|
51
|
+
dsc.sampled = String(sampled);
|
|
52
|
+
|
|
53
|
+
client.emit('createDsc', dsc);
|
|
54
|
+
|
|
55
|
+
return dsc;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { getDynamicSamplingContextFromSpan };
|
|
59
|
+
//# sourceMappingURL=dynamicSamplingContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamicSamplingContext.js","sources":["../../../src/utils/dynamicSamplingContext.ts"],"sourcesContent":["import { TraceFlags } from '@opentelemetry/api';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getClient,\n getDynamicSamplingContextFromClient,\n} from '@sentry/core';\nimport type { DynamicSamplingContext } from '@sentry/types';\nimport { baggageHeaderToDynamicSamplingContext } from '@sentry/utils';\nimport { SENTRY_TRACE_STATE_DSC } from '../constants';\nimport type { AbstractSpan } from '../types';\nimport { spanHasAttributes, spanHasName } from './spanTypes';\n\n/**\n * Creates a dynamic sampling context from a span (and client and scope)\n *\n * @param span the span from which a few values like the root span name and sample rate are extracted.\n *\n * @returns a dynamic sampling context\n */\nexport function getDynamicSamplingContextFromSpan(span: AbstractSpan): Readonly<Partial<DynamicSamplingContext>> {\n const client = getClient();\n if (!client) {\n return {};\n }\n\n const traceState = span.spanContext().traceState;\n const traceStateDsc = traceState?.get(SENTRY_TRACE_STATE_DSC);\n\n // If the span has a DSC, we want it to take precedence\n const dscOnSpan = traceStateDsc ? baggageHeaderToDynamicSamplingContext(traceStateDsc) : undefined;\n\n if (dscOnSpan) {\n return dscOnSpan;\n }\n\n const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);\n\n const attributes = spanHasAttributes(span) ? span.attributes : {};\n\n const sampleRate = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];\n if (sampleRate != null) {\n dsc.sample_rate = `${sampleRate}`;\n }\n\n // We don't want to have a transaction name in the DSC if the source is \"url\" because URLs might contain PII\n const source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n const name = spanHasName(span) ? span.name : '';\n\n if (source !== 'url' && name) {\n dsc.transaction = name;\n }\n\n // TODO: Once we aligned span types, use spanIsSampled() from core instead\n // eslint-disable-next-line no-bitwise\n const sampled = Boolean(span.spanContext().traceFlags & TraceFlags.SAMPLED);\n dsc.sampled = String(sampled);\n\n client.emit('createDsc', dsc);\n\n return dsc;\n}\n"],"names":[],"mappings":";;;;;;;AAaA,CAAA,CAAA;CACA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA;CACA;CACA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;CACA;CACA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAA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AA;;EAEA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,GAAA;AACA;;"}
|
package/esm/utils/mapStatus.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SpanStatusCode } from '@opentelemetry/api';
|
|
2
2
|
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
|
|
3
|
+
import { SPAN_STATUS_ERROR, SPAN_STATUS_OK } from '@sentry/core';
|
|
3
4
|
import { spanHasAttributes, spanHasStatus } from './spanTypes.js';
|
|
4
5
|
|
|
5
6
|
// canonicalCodesHTTPMap maps some HTTP codes to Sentry's span statuses. See possible mapping in https://develop.sentry.dev/sdk/event-payloads/span/
|
|
@@ -51,23 +52,23 @@ function mapStatus(span) {
|
|
|
51
52
|
if (code) {
|
|
52
53
|
const sentryStatus = canonicalCodesHTTPMap[code];
|
|
53
54
|
if (sentryStatus) {
|
|
54
|
-
return sentryStatus;
|
|
55
|
+
return { code: SPAN_STATUS_ERROR, message: sentryStatus };
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
if (typeof grpcCode === 'string') {
|
|
59
60
|
const sentryStatus = canonicalCodesGrpcMap[grpcCode];
|
|
60
61
|
if (sentryStatus) {
|
|
61
|
-
return sentryStatus;
|
|
62
|
+
return { code: SPAN_STATUS_ERROR, message: sentryStatus };
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
const statusCode = status && status.code;
|
|
66
67
|
if (statusCode === SpanStatusCode.OK || statusCode === SpanStatusCode.UNSET) {
|
|
67
|
-
return
|
|
68
|
+
return { code: SPAN_STATUS_OK };
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
return 'unknown_error';
|
|
71
|
+
return { code: SPAN_STATUS_ERROR, message: 'unknown_error' };
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
export { mapStatus };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapStatus.js","sources":["../../../src/utils/mapStatus.ts"],"sourcesContent":["import { SpanStatusCode } from '@opentelemetry/api';\nimport { SemanticAttributes } from '@opentelemetry/semantic-conventions';\nimport
|
|
1
|
+
{"version":3,"file":"mapStatus.js","sources":["../../../src/utils/mapStatus.ts"],"sourcesContent":["import { SpanStatusCode } from '@opentelemetry/api';\nimport { SemanticAttributes } from '@opentelemetry/semantic-conventions';\nimport { SPAN_STATUS_ERROR, SPAN_STATUS_OK } from '@sentry/core';\nimport type { SpanStatus } from '@sentry/types';\n\nimport type { AbstractSpan } from '../types';\nimport { spanHasAttributes, spanHasStatus } from './spanTypes';\n\n// canonicalCodesHTTPMap maps some HTTP codes to Sentry's span statuses. See possible mapping in https://develop.sentry.dev/sdk/event-payloads/span/\nconst canonicalCodesHTTPMap: Record<string, SpanStatus['message']> = {\n '400': 'failed_precondition',\n '401': 'unauthenticated',\n '403': 'permission_denied',\n '404': 'not_found',\n '409': 'aborted',\n '429': 'resource_exhausted',\n '499': 'cancelled',\n '500': 'internal_error',\n '501': 'unimplemented',\n '503': 'unavailable',\n '504': 'deadline_exceeded',\n} as const;\n\n// canonicalCodesGrpcMap maps some GRPC codes to Sentry's span statuses. See description in grpc documentation.\nconst canonicalCodesGrpcMap: Record<string, SpanStatus['message']> = {\n '1': 'cancelled',\n '2': 'unknown_error',\n '3': 'invalid_argument',\n '4': 'deadline_exceeded',\n '5': 'not_found',\n '6': 'already_exists',\n '7': 'permission_denied',\n '8': 'resource_exhausted',\n '9': 'failed_precondition',\n '10': 'aborted',\n '11': 'out_of_range',\n '12': 'unimplemented',\n '13': 'internal_error',\n '14': 'unavailable',\n '15': 'data_loss',\n '16': 'unauthenticated',\n} as const;\n\n/**\n * Get a Sentry span status from an otel span.\n */\nexport function mapStatus(span: AbstractSpan): SpanStatus {\n const attributes = spanHasAttributes(span) ? span.attributes : {};\n const status = spanHasStatus(span) ? span.status : undefined;\n\n const httpCode = attributes[SemanticAttributes.HTTP_STATUS_CODE];\n const grpcCode = attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n\n const code = typeof httpCode === 'string' ? httpCode : typeof httpCode === 'number' ? httpCode.toString() : undefined;\n if (code) {\n const sentryStatus = canonicalCodesHTTPMap[code];\n if (sentryStatus) {\n return { code: SPAN_STATUS_ERROR, message: sentryStatus };\n }\n }\n\n if (typeof grpcCode === 'string') {\n const sentryStatus = canonicalCodesGrpcMap[grpcCode];\n if (sentryStatus) {\n return { code: SPAN_STATUS_ERROR, message: sentryStatus };\n }\n }\n\n const statusCode = status && status.code;\n if (statusCode === SpanStatusCode.OK || statusCode === SpanStatusCode.UNSET) {\n return { code: SPAN_STATUS_OK };\n }\n\n return { code: SPAN_STATUS_ERROR, message: 'unknown_error' };\n}\n"],"names":[],"mappings":";;;;;AAQA;AACA,MAAM,qBAAqB,GAA0C;AACrE,EAAE,KAAK,EAAE,qBAAqB;AAC9B,EAAE,KAAK,EAAE,iBAAiB;AAC1B,EAAE,KAAK,EAAE,mBAAmB;AAC5B,EAAE,KAAK,EAAE,WAAW;AACpB,EAAE,KAAK,EAAE,SAAS;AAClB,EAAE,KAAK,EAAE,oBAAoB;AAC7B,EAAE,KAAK,EAAE,WAAW;AACpB,EAAE,KAAK,EAAE,gBAAgB;AACzB,EAAE,KAAK,EAAE,eAAe;AACxB,EAAE,KAAK,EAAE,aAAa;AACtB,EAAE,KAAK,EAAE,mBAAmB;AAC5B,CAAE,EAAA;AACF;AACA;AACA,MAAM,qBAAqB,GAA0C;AACrE,EAAE,GAAG,EAAE,WAAW;AAClB,EAAE,GAAG,EAAE,eAAe;AACtB,EAAE,GAAG,EAAE,kBAAkB;AACzB,EAAE,GAAG,EAAE,mBAAmB;AAC1B,EAAE,GAAG,EAAE,WAAW;AAClB,EAAE,GAAG,EAAE,gBAAgB;AACvB,EAAE,GAAG,EAAE,mBAAmB;AAC1B,EAAE,GAAG,EAAE,oBAAoB;AAC3B,EAAE,GAAG,EAAE,qBAAqB;AAC5B,EAAE,IAAI,EAAE,SAAS;AACjB,EAAE,IAAI,E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UAAU,MAAM,CAAC,IAAI,CAAA;AAC1C,EAAE,IAAI,UAAW,KAAI,cAAc,CAAC,EAAG,IAAG,UAAW,KAAI,cAAc,CAAC,KAAK,EAAE;AAC/E,IAAI,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAA;AACnC,GAAE;AACF;AACA,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,eAAA,EAAiB,CAAA;AAC9D;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const setupElements = new Set();
|
|
2
|
+
|
|
3
|
+
/** Get all the OpenTelemetry elements that have been set up. */
|
|
4
|
+
function openTelemetrySetupCheck() {
|
|
5
|
+
return Array.from(setupElements);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Mark an OpenTelemetry element as setup. */
|
|
9
|
+
function setIsSetup(element) {
|
|
10
|
+
setupElements.add(element);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { openTelemetrySetupCheck, setIsSetup };
|
|
14
|
+
//# sourceMappingURL=setupCheck.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupCheck.js","sources":["../../../src/utils/setupCheck.ts"],"sourcesContent":["type OpenTelemetryElement = 'SentrySpanProcessor' | 'SentryContextManager' | 'SentryPropagator' | 'SentrySampler';\n\nconst setupElements = new Set<OpenTelemetryElement>();\n\n/** Get all the OpenTelemetry elements that have been set up. */\nexport function openTelemetrySetupCheck(): OpenTelemetryElement[] {\n return Array.from(setupElements);\n}\n\n/** Mark an OpenTelemetry element as setup. */\nexport function setIsSetup(element: OpenTelemetryElement): void {\n setupElements.add(element);\n}\n\n/** Only exported for tests. */\nexport function clearOpenTelemetrySetupCheck(): void {\n setupElements.clear();\n}\n"],"names":[],"mappings":"AAEA,MAAM,aAAc,GAAE,IAAI,GAAG,EAAwB,CAAA;AACrD;AACA;AACO,SAAS,uBAAuB,GAA2B;AAClE,EAAE,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;AAClC,CAAA;AACA;AACA;AACO,SAAS,UAAU,CAAC,OAAO,EAA8B;AAChE,EAAE,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AAC5B;;;;"}
|
package/esm/utils/spanData.js
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
// We store the parent span,
|
|
1
|
+
// We store the parent span, scopes & metadata in separate weakmaps, so we can access them for a given span
|
|
2
2
|
// This way we can enhance the data that an OTEL Span natively gives us
|
|
3
3
|
// and since we are using weakmaps, we do not need to clean up after ourselves
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const SpanScopes = new WeakMap
|
|
5
|
+
|
|
6
|
+
();
|
|
6
7
|
const SpanHub = new WeakMap();
|
|
7
8
|
const SpanParent = new WeakMap();
|
|
8
9
|
const SpanMetadata = new WeakMap();
|
|
9
10
|
|
|
10
|
-
/** Set the Sentry scope on an OTEL span. */
|
|
11
|
-
function setSpanScope(span, scope) {
|
|
12
|
-
SpanScope.set(span, scope);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** Get the Sentry scope of an OTEL span. */
|
|
16
|
-
function getSpanScope(span) {
|
|
17
|
-
return SpanScope.get(span);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
11
|
/** Set the Sentry hub on an OTEL span. */
|
|
21
12
|
function setSpanHub(span, hub) {
|
|
22
13
|
SpanHub.set(span, hub);
|
|
@@ -47,15 +38,26 @@ function getSpanMetadata(span) {
|
|
|
47
38
|
return SpanMetadata.get(span);
|
|
48
39
|
}
|
|
49
40
|
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Set the Sentry scope to be used for finishing a given OTEL span.
|
|
43
|
+
* This is different from `setCapturedScopesOnSpan`, as that works on _sentry_ spans,
|
|
44
|
+
* while here we are basically "caching" this on the otel spans.
|
|
45
|
+
*/
|
|
46
|
+
function setSpanScopes(
|
|
47
|
+
span,
|
|
48
|
+
scopes
|
|
49
|
+
|
|
50
|
+
,
|
|
51
|
+
) {
|
|
52
|
+
SpanScopes.set(span, scopes);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/** Get the Sentry
|
|
56
|
-
function
|
|
57
|
-
|
|
55
|
+
/** Get the Sentry scopes to use for finishing an OTEL span. */
|
|
56
|
+
function getSpanScopes(span)
|
|
57
|
+
|
|
58
|
+
{
|
|
59
|
+
return SpanScopes.get(span);
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
export {
|
|
62
|
+
export { getSpanHub, getSpanMetadata, getSpanParent, getSpanScopes, setSpanHub, setSpanMetadata, setSpanParent, setSpanScopes };
|
|
61
63
|
//# sourceMappingURL=spanData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spanData.js","sources":["../../../src/utils/spanData.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { Hub, Scope, TransactionMetadata } from '@sentry/types';\n\nimport type { AbstractSpan } from '../types';\n\n// We store the parent span,
|
|
1
|
+
{"version":3,"file":"spanData.js","sources":["../../../src/utils/spanData.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { Hub, Scope, TransactionMetadata } from '@sentry/types';\n\nimport type { AbstractSpan } from '../types';\n\n// We store the parent span, scopes & metadata in separate weakmaps, so we can access them for a given span\n// This way we can enhance the data that an OTEL Span natively gives us\n// and since we are using weakmaps, we do not need to clean up after ourselves\nconst SpanScopes = new WeakMap<\n AbstractSpan,\n {\n scope: Scope;\n isolationScope: Scope;\n }\n>();\nconst SpanHub = new WeakMap<AbstractSpan, Hub>();\nconst SpanParent = new WeakMap<AbstractSpan, Span>();\nconst SpanMetadata = new WeakMap<AbstractSpan, Partial<TransactionMetadata>>();\n\n/** Set the Sentry hub on an OTEL span. */\nexport function setSpanHub(span: AbstractSpan, hub: Hub): void {\n SpanHub.set(span, hub);\n}\n\n/** Get the Sentry hub of an OTEL span. */\nexport function getSpanHub(span: AbstractSpan): Hub | undefined {\n return SpanHub.get(span);\n}\n\n/** Set the parent OTEL span on an OTEL span. */\nexport function setSpanParent(span: AbstractSpan, parentSpan: Span): void {\n SpanParent.set(span, parentSpan);\n}\n\n/** Get the parent OTEL span of an OTEL span. */\nexport function getSpanParent(span: AbstractSpan): Span | undefined {\n return SpanParent.get(span);\n}\n\n/** Set metadata for an OTEL span. */\nexport function setSpanMetadata(span: AbstractSpan, metadata: Partial<TransactionMetadata>): void {\n SpanMetadata.set(span, metadata);\n}\n\n/** Get metadata for an OTEL span. */\nexport function getSpanMetadata(span: AbstractSpan): Partial<TransactionMetadata> | undefined {\n return SpanMetadata.get(span);\n}\n\n/**\n * Set the Sentry scope to be used for finishing a given OTEL span.\n * This is different from `setCapturedScopesOnSpan`, as that works on _sentry_ spans,\n * while here we are basically \"caching\" this on the otel spans.\n */\nexport function setSpanScopes(\n span: AbstractSpan,\n scopes: {\n scope: Scope;\n isolationScope: Scope;\n },\n): void {\n SpanScopes.set(span, scopes);\n}\n\n/** Get the Sentry scopes to use for finishing an OTEL span. */\nexport function getSpanScopes(span: AbstractSpan):\n | {\n scope: Scope;\n isolationScope: Scope;\n }\n | undefined {\n return SpanScopes.get(span);\n}\n"],"names":[],"mappings":"AAKA;AACA;AACA;AACA,MAAM,UAAA,GAAa,IAAI,OAAO;;AAM9B,EAAG,CAAA;AACH,MAAM,OAAQ,GAAE,IAAI,OAAO,EAAqB,CAAA;AAChD,MAAM,UAAW,GAAE,IAAI,OAAO,EAAsB,CAAA;AACpD,MAAM,YAAa,GAAE,IAAI,OAAO,EAA8C,CAAA;AAC9E;AACA;AACO,SAAS,UAAU,CAAC,IAAI,EAAgB,GAAG,EAAa;AAC/D,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AACxB,CAAA;AACA;AACA;AACO,SAAS,UAAU,CAAC,IAAI,EAAiC;AAChE,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAA;AACA;AACA;AACO,SAAS,aAAa,CAAC,IAAI,EAAgB,UAAU,EAAc;AAC1E,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;AAClC,CAAA;AACA;AACA;AACO,SAAS,aAAa,CAAC,IAAI,EAAkC;AACpE,EAAE,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAA;AACA;AACA;AACO,SAAS,eAAe,CAAC,IAAI,EAAgB,QAAQ,EAAsC;AAClG,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAClC,CAAA;AACA;AACA;AACO,SAAS,eAAe,CAAC,IAAI,EAA0D;AAC9F,EAAE,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa;AAC7B,EAAE,IAAI;AACN,EAAE,MAAM;;AAGN;AACF,EAAQ;AACR,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAC9B,CAAA;AACA;AACA;AACO,SAAS,aAAa,CAAC,IAAI;;AAKhC,CAAY;AACd,EAAE,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC7B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/opentelemetry",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.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",
|
|
7
7
|
"author": "Sentry",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=14"
|
|
10
|
+
"node": ">=14.8"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"cjs",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@sentry/core": "
|
|
33
|
-
"@sentry/types": "
|
|
34
|
-
"@sentry/utils": "
|
|
32
|
+
"@sentry/core": "8.0.0-alpha.2",
|
|
33
|
+
"@sentry/types": "8.0.0-alpha.2",
|
|
34
|
+
"@sentry/utils": "8.0.0-alpha.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@opentelemetry/api": "^1.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncContextStrategy.d.ts","sourceRoot":"","sources":["../../src/asyncContextStrategy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"asyncContextStrategy.d.ts","sourceRoot":"","sources":["../../src/asyncContextStrategy.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wBAAgB,2CAA2C,IAAI,IAAI,CAkGlE"}
|
package/types/constants.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export declare const SENTRY_TRACE_HEADER = "sentry-trace";
|
|
2
2
|
export declare const SENTRY_BAGGAGE_HEADER = "baggage";
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const SENTRY_TRACE_STATE_DSC = "sentry.trace";
|
|
4
|
+
export declare const SENTRY_TRACE_STATE_PARENT_SPAN_ID = "sentry.parent_span_id";
|
|
5
5
|
/** Context Key to hold a Hub. */
|
|
6
6
|
export declare const SENTRY_HUB_CONTEXT_KEY: symbol;
|
|
7
|
+
export declare const SENTRY_SCOPES_CONTEXT_KEY: symbol;
|
|
8
|
+
export declare const SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY: symbol;
|
|
9
|
+
export declare const SENTRY_FORK_SET_SCOPE_CONTEXT_KEY: symbol;
|
|
10
|
+
export declare const SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY: symbol;
|
|
7
11
|
//# sourceMappingURL=constants.d.ts.map
|
package/types/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,qBAAqB,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAC/C,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AACrD,eAAO,MAAM,iCAAiC,0BAA0B,CAAC;AAEzE,iCAAiC;AACjC,eAAO,MAAM,sBAAsB,QAAiC,CAAC;AAErE,eAAO,MAAM,yBAAyB,QAAoC,CAAC;AAE3E,eAAO,MAAM,uCAAuC,QAAkD,CAAC;AAEvG,eAAO,MAAM,iCAAiC,QAA4C,CAAC;AAE3F,eAAO,MAAM,2CAA2C,QAAsD,CAAC"}
|
|
@@ -7,5 +7,5 @@ import type { ContextManager } from '@opentelemetry/api';
|
|
|
7
7
|
* const SentryContextManager = wrapContextManagerClass(AsyncLocalStorageContextManager);
|
|
8
8
|
* const contextManager = new SentryContextManager();
|
|
9
9
|
*/
|
|
10
|
-
export declare function wrapContextManagerClass<ContextManagerInstance extends ContextManager>(ContextManagerClass: new (...args:
|
|
10
|
+
export declare function wrapContextManagerClass<ContextManagerInstance extends ContextManager>(ContextManagerClass: new (...args: unknown[]) => ContextManagerInstance): typeof ContextManagerClass;
|
|
11
11
|
//# sourceMappingURL=contextManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextManager.d.ts","sourceRoot":"","sources":["../../src/contextManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"contextManager.d.ts","sourceRoot":"","sources":["../../src/contextManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAalE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,sBAAsB,SAAS,cAAc,EACnF,mBAAmB,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,sBAAsB,GACtE,OAAO,mBAAmB,CA6D5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/custom/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/custom/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,mBAAmB,IAAI,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAMpF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,gBAAgB,SAAS,KACvB,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,EAC7B,uBAAuB,SAAS,KAC9B,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,4BAA4B,EAC5D,WAAW,EAAE,gBAAgB,GAAG,uBAAuB,CAuCxD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Hub } from '@sentry/types';
|
|
2
|
+
/**
|
|
3
|
+
* This is for legacy reasons, and returns a proxy object instead of a hub to be used.
|
|
4
|
+
* @deprecated Use the methods directly.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getCurrentHub(): Hub;
|
|
7
|
+
//# sourceMappingURL=getCurrentHub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrentHub.d.ts","sourceRoot":"","sources":["../../../src/custom/getCurrentHub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,GAAG,EAMJ,MAAM,eAAe,CAAC;AAmBvB;;;GAGG;AACH,wBAAgB,aAAa,IAAI,GAAG,CA6EnC"}
|
package/types/custom/hub.d.ts
CHANGED
|
@@ -1,38 +1,7 @@
|
|
|
1
|
-
import type { Carrier, Scope } from '@sentry/core';
|
|
2
|
-
import { Hub } from '@sentry/core';
|
|
3
|
-
import type { Client } from '@sentry/types';
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Exported only for testing
|
|
7
|
-
*/
|
|
8
|
-
export declare class OpenTelemetryHub extends Hub {
|
|
9
|
-
constructor(client?: Client, scope?: Scope);
|
|
10
|
-
}
|
|
11
|
-
/** Custom getClient method that uses the custom hub. */
|
|
12
|
-
export declare function getClient<C extends Client>(): C | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Returns the default hub instance.
|
|
2
|
+
* Ensure the global hub is setup.
|
|
15
3
|
*
|
|
16
|
-
*
|
|
17
|
-
* contains a more recent version, it replaces the registered version.
|
|
18
|
-
* Otherwise, the currently registered hub will be returned.
|
|
19
|
-
*/
|
|
20
|
-
export declare function getCurrentHub(): Hub;
|
|
21
|
-
/**
|
|
22
|
-
* Ensure the global hub is an OpenTelemetryHub.
|
|
4
|
+
* @deprecated This will be removed in the next major version.
|
|
23
5
|
*/
|
|
24
6
|
export declare function setupGlobalHub(): void;
|
|
25
|
-
/**
|
|
26
|
-
* This will create a new {@link Hub} and add to the passed object on
|
|
27
|
-
* __SENTRY__.hub.
|
|
28
|
-
* @param carrier object
|
|
29
|
-
* @hidden
|
|
30
|
-
*/
|
|
31
|
-
export declare function getHubFromCarrier(carrier: Carrier): Hub;
|
|
32
|
-
/**
|
|
33
|
-
* @private Private API with no semver guarantees!
|
|
34
|
-
*
|
|
35
|
-
* If the carrier does not contain a hub, a new hub is created with the global hub client and scope.
|
|
36
|
-
*/
|
|
37
|
-
export declare function ensureHubOnCarrier(carrier: Carrier, parent?: Hub): void;
|
|
38
7
|
//# sourceMappingURL=hub.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../../src/custom/hub.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../../src/custom/hub.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { Transaction } from '@sentry/core';
|
|
2
|
-
import type { Hub as HubInterface,
|
|
2
|
+
import type { Hub as HubInterface, TransactionContext } from '@sentry/types';
|
|
3
3
|
/**
|
|
4
4
|
* This is a fork of core's tracing/hubextensions.ts _startTransaction,
|
|
5
5
|
* with some OTEL specifics.
|
|
6
6
|
*/
|
|
7
7
|
export declare function startTransaction(hub: HubInterface, transactionContext: TransactionContext): Transaction;
|
|
8
|
-
/**
|
|
9
|
-
* This is a fork of the base Transaction with OTEL specific stuff added.
|
|
10
|
-
*/
|
|
11
|
-
export declare class OpenTelemetryTransaction extends Transaction {
|
|
12
|
-
/**
|
|
13
|
-
* Finish the transaction, but apply the given scope instead of the current one.
|
|
14
|
-
*/
|
|
15
|
-
finishWithScope(endTimestamp?: number, scope?: Scope): string | undefined;
|
|
16
|
-
}
|
|
17
8
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/custom/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/custom/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,GAAG,IAAI,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE7E;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,GAAG,WAAW,CAcvG"}
|
package/types/index.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ import { getRequestSpanData } from './utils/getRequestSpanData';
|
|
|
4
4
|
export type { OpenTelemetryClient } from './types';
|
|
5
5
|
export { wrapClientClass } from './custom/client';
|
|
6
6
|
export { getSpanKind } from './utils/getSpanKind';
|
|
7
|
-
export { getSpanHub, getSpanMetadata, getSpanParent,
|
|
8
|
-
export {
|
|
7
|
+
export { getSpanHub, getSpanMetadata, getSpanParent, setSpanMetadata, getSpanScopes, } from './utils/spanData';
|
|
8
|
+
export { getScopesFromContext } from './utils/contextData';
|
|
9
9
|
export { spanHasAttributes, spanHasEvents, spanHasKind, spanHasName, spanHasParentId, spanHasStatus, } from './utils/spanTypes';
|
|
10
10
|
export { isSentryRequestSpan } from './utils/isSentryRequest';
|
|
11
11
|
export { getActiveSpan, getRootSpan } from './utils/getActiveSpan';
|
|
12
|
-
export { startSpan, startSpanManual, startInactiveSpan } from './trace';
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
12
|
+
export { startSpan, startSpanManual, startInactiveSpan, withActiveSpan } from './trace';
|
|
13
|
+
export { setupGlobalHub } from './custom/hub';
|
|
14
|
+
export { getCurrentHub } from './custom/getCurrentHub';
|
|
15
15
|
export { addTracingExtensions } from './custom/hubextensions';
|
|
16
16
|
export { setupEventContextTrace } from './setupEventContextTrace';
|
|
17
17
|
export { setOpenTelemetryContextAsyncContextStrategy } from './asyncContextStrategy';
|
|
@@ -19,6 +19,8 @@ export { wrapContextManagerClass } from './contextManager';
|
|
|
19
19
|
export { SentryPropagator } from './propagator';
|
|
20
20
|
export { SentrySpanProcessor } from './spanProcessor';
|
|
21
21
|
export { SentrySampler } from './sampler';
|
|
22
|
+
export { openTelemetrySetupCheck } from './utils/setupCheck';
|
|
23
|
+
export { getClient } from '@sentry/core';
|
|
22
24
|
/**
|
|
23
25
|
* The following internal utils are not considered public API and are subject to change.
|
|
24
26
|
* @hidden
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,UAAU,EACV,eAAe,EACf,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,UAAU,EACV,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,E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