Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const api = require('@opentelemetry/api'); const core = require('@sentry/core'); const debugBuild = require('../debug-build.js'); const SENTRY_TRACE_LINK_KEY_PREFIX = "__SENTRY_TRACE_LINK__"; function getTraceLinkKey(methodName) { return `${SENTRY_TRACE_LINK_KEY_PREFIX}${methodName}`; } function storeSpanContext(originalStorage, methodName) { try { const activeSpan = core.getActiveSpan(); if (activeSpan) { const spanContext = activeSpan.spanContext(); const storedContext = { traceId: spanContext.traceId, spanId: spanContext.spanId, sampled: core.spanIsSampled(activeSpan) }; originalStorage.kv.put(getTraceLinkKey(methodName), storedContext); } } catch (error) { debugBuild.DEBUG_BUILD && core.debug.log(`[CloudflareClient] Error storing span context for method ${methodName}`, error); } } function getStoredSpanContext(originalStorage, methodName) { try { return originalStorage.kv.get(getTraceLinkKey(methodName)); } catch (error) { debugBuild.DEBUG_BUILD && core.debug.log(`[CloudflareClient] Error retrieving span context for method ${methodName}`, error); return void 0; } } function buildSpanLinks(storedContext) { return [ { context: { traceId: storedContext.traceId, spanId: storedContext.spanId, traceFlags: storedContext.sampled ? api.TraceFlags.SAMPLED : api.TraceFlags.NONE }, attributes: { [core.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: "previous_trace" } } ]; } exports.buildSpanLinks = buildSpanLinks; exports.getStoredSpanContext = getStoredSpanContext; exports.getTraceLinkKey = getTraceLinkKey; exports.storeSpanContext = storeSpanContext; //# sourceMappingURL=traceLinks.js.map