45 lines
1.8 KiB
JavaScript
45 lines
1.8 KiB
JavaScript
// Metro module 6439 (f6440).
|
|
import "./errorCallback";
|
|
import "./Module6367";
|
|
import "./Module6396";
|
|
import "./Module6382";
|
|
import { getClient, getCurrentScope } from "./Module6395";
|
|
import { isEnabled } from "./endSession";
|
|
import { getMainCarrier } from "./Module6386";
|
|
import { getAsyncContextStrategy } from "./Module6387";
|
|
import { getActiveSpan, spanToTraceHeader } from "./spanTimeInputToSeconds";
|
|
import { getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromScope } from "./getDynamicSamplingContextFromSpan_6404";
|
|
import { dynamicSamplingContextToSentryBaggageHeader } from "./Module6381";
|
|
import { generateSentryTraceHeader, TRACEPARENT_REGEXP } from "./Module6380";
|
|
import { logger } from "./consoleSandbox_6368";
|
|
export function getTraceData(r3 = {}) {
|
|
let r39, r63;
|
|
const client = getClient();
|
|
if (isEnabled() && client) {
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
if (asyncContextStrategy.getTraceData) {
|
|
return asyncContextStrategy.getTraceData(r3);
|
|
}
|
|
const currentScope = getCurrentScope();
|
|
const r9 = r3.span || getActiveSpan();
|
|
if (r9) {
|
|
r39 = spanToTraceHeader(r9);
|
|
} else {
|
|
const propagationContext = currentScope.getPropagationContext();
|
|
r39 = generateSentryTraceHeader(propagationContext.traceId, propagationContext.spanId, propagationContext.sampled);
|
|
}
|
|
const baggage = dynamicSamplingContextToSentryBaggageHeader(r9 ? getDynamicSamplingContextFromSpan(r9) : getDynamicSamplingContextFromScope(client, currentScope));
|
|
if (TRACEPARENT_REGEXP.test(r39)) {
|
|
r63 = {
|
|
"sentry-trace": r39,
|
|
baggage
|
|
};
|
|
} else {
|
|
logger.warn("Invalid sentry-trace data. Cannot generate trace data");
|
|
r63 = {};
|
|
}
|
|
return r63;
|
|
}
|
|
return {};
|
|
}
|