52 lines
2.2 KiB
JavaScript
52 lines
2.2 KiB
JavaScript
// Metro module 904 (f905).
|
|
import { getClient, getCurrentScope } from "./Module848";
|
|
import { isEnabled } from "./captureCheckIn";
|
|
import { getMainCarrier } from "./Module825";
|
|
import { getAsyncContextStrategy } from "./Module841";
|
|
import { getActiveSpan, spanToTraceHeader, spanToTraceparentHeader } from "./spanToJSON";
|
|
import { getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromScope } from "./getDynamicSamplingContextFromSpan";
|
|
import { dynamicSamplingContextToSentryBaggageHeader } from "./Module835";
|
|
import { generateSentryTraceHeader, TRACEPARENT_REGEXP, generateTraceparentHeader } from "./Module834";
|
|
import { debug } from "./consoleSandbox";
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
export function getTraceData(r3 = {}) {
|
|
let r41, traceparent;
|
|
const r10 = r3.client || getClient();
|
|
if (isEnabled() && r10) {
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
if (asyncContextStrategy.getTraceData) {
|
|
return asyncContextStrategy.getTraceData(r3);
|
|
}
|
|
const r8 = r3.scope || getCurrentScope();
|
|
const r7 = r3.span || getActiveSpan();
|
|
if (r7) {
|
|
r41 = spanToTraceHeader(r7);
|
|
} else {
|
|
const propagationContext = r8.getPropagationContext();
|
|
r41 = generateSentryTraceHeader(propagationContext.traceId, propagationContext.propagationSpanId, propagationContext.sampled);
|
|
}
|
|
const baggage = dynamicSamplingContextToSentryBaggageHeader(r7 ? getDynamicSamplingContextFromSpan(r7) : getDynamicSamplingContextFromScope(r10, r8));
|
|
if (TRACEPARENT_REGEXP.test(r41)) {
|
|
const r66 = {
|
|
"sentry-trace": r41,
|
|
baggage
|
|
};
|
|
if (r3.propagateTraceparent) {
|
|
if (r7) {
|
|
traceparent = spanToTraceparentHeader(r7);
|
|
} else {
|
|
const propagationContext2 = r8.getPropagationContext();
|
|
traceparent = generateTraceparentHeader(propagationContext2.traceId, propagationContext2.propagationSpanId, propagationContext2.sampled);
|
|
}
|
|
r66.traceparent = traceparent;
|
|
}
|
|
return r66;
|
|
}
|
|
debug.warn("Invalid sentry-trace data. Cannot generate trace data");
|
|
return {};
|
|
}
|
|
return {};
|
|
}
|