356 lines
12 KiB
JavaScript
356 lines
12 KiB
JavaScript
// Metro module 6402 (f6403).
|
|
import { getIsolationScope, getClient, withScope, getCurrentScope } from "./Module6395";
|
|
import { SentryNonRecordingSpan } from "./SentryNonRecordingSpan_6401";
|
|
import { _getSpanForScope, _setSpanForScope } from "./Module6390";
|
|
import { handleCallbackErrors } from "./Module6403";
|
|
import { spanIsSampled, addChildSpanToSpan, spanTimeInputToSeconds, getRootSpan, spanToJSON } from "./spanTimeInputToSeconds";
|
|
import { SPAN_STATUS_ERROR } from "./Module6385";
|
|
import { getMainCarrier } from "./Module6386";
|
|
import { getAsyncContextStrategy } from "./Module6387";
|
|
import { propagationContextFromHeaders } from "./Module6380";
|
|
import { generateTraceId } from "./Module6378";
|
|
import { DEBUG_BUILD } from "./Module6396";
|
|
import { logger } from "./consoleSandbox_6368";
|
|
import { hasTracingEnabled } from "./Module6400";
|
|
import { getDynamicSamplingContextFromSpan, freezeDscOnSpan } from "./getDynamicSamplingContextFromSpan_6404";
|
|
import { logSpanStart } from "./Module6406";
|
|
import { setCapturedScopesOnSpan } from "./Module6397";
|
|
import { sampleSpan } from "./Module6407";
|
|
import { SentrySpan } from "./isFullFinishedSpan_6409";
|
|
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE } from "./Module6383";
|
|
import { HermesBuiltin } from "../_hermes/prelude";
|
|
function $mk78495($env) {
|
|
return (a0) => {
|
|
const r1 = $env;
|
|
const r2 = $env.$parent;
|
|
(0, r2[0])(r2[1][3])._setSpanForScope(a0, r1[0] || void 0);
|
|
return (0, r1[1])(a0);
|
|
};
|
|
}
|
|
function $mk78496($env) {
|
|
return (a0) => {
|
|
let env25847;
|
|
const r2 = $env.$parent;
|
|
const r4 = $env[0];
|
|
const r9 = env25847 = {
|
|
$parent: r2
|
|
};
|
|
env25847[0] = r4;
|
|
env25847[1] = a0;
|
|
const r6 = r2[0];
|
|
const r10 = r2[1];
|
|
const mainCarrier = r6(r10[7]).getMainCarrier();
|
|
const asyncContextStrategy = r6(r10[8]).getAsyncContextStrategy(mainCarrier);
|
|
return asyncContextStrategy.withActiveSpan ? asyncContextStrategy.withActiveSpan(r4, a0) : r6(r10[1]).withScope($mk78495(r9));
|
|
};
|
|
}
|
|
function $mk78497() {
|
|
return (a0) => a0();
|
|
}
|
|
let _startRootSpan, c4100_3;
|
|
let env4100 = {};
|
|
const createChildOrRootSpan = function createChildOrRootSpan({ parentSpan: parentSpan4, spanArguments: spanArguments4, forceTransaction: forceTransaction4, scope }) {
|
|
let r48;
|
|
if (hasTracingEnabled()) {
|
|
const isolationScope = getIsolationScope();
|
|
if (parentSpan4 && !forceTransaction4) {
|
|
const r33 = parentSpan4.spanContext();
|
|
const { spanId, traceId } = r33;
|
|
const r38 = scope.getScopeData().sdkProcessingMetadata[c4100_3];
|
|
const sampled = r38 ? !r38 : spanIsSampled(parentSpan4);
|
|
r48 = sampled ? new SentrySpan({
|
|
...spanArguments4,
|
|
parentSpanId: spanId,
|
|
traceId,
|
|
sampled
|
|
}) : new SentryNonRecordingSpan({
|
|
traceId
|
|
});
|
|
addChildSpanToSpan(parentSpan4, r48);
|
|
const client = getClient();
|
|
if (client) {
|
|
client.emit("spanStart", r48);
|
|
if (spanArguments4.endTimestamp) {
|
|
client.emit("spanEnd", r48);
|
|
}
|
|
}
|
|
addChildSpanToSpan(parentSpan4, r48);
|
|
} else if (parentSpan4) {
|
|
const dynamicSamplingContextFromSpan = getDynamicSamplingContextFromSpan(parentSpan4);
|
|
const r105 = parentSpan4.spanContext();
|
|
const r117 = _startRootSpan({
|
|
traceId: r105.traceId,
|
|
parentSpanId: r105.spanId,
|
|
...spanArguments4
|
|
}, scope, spanIsSampled(parentSpan4));
|
|
freezeDscOnSpan(r117, dynamicSamplingContextFromSpan);
|
|
r48 = r117;
|
|
} else {
|
|
const r77 = {
|
|
...isolationScope.getPropagationContext(),
|
|
...scope.getPropagationContext()
|
|
};
|
|
const { traceId: traceId2, dsc } = r77;
|
|
const r95 = _startRootSpan({
|
|
traceId: traceId2,
|
|
parentSpanId: r77.parentSpanId,
|
|
...spanArguments4
|
|
}, scope, r77.sampled);
|
|
r48 = r95;
|
|
if (dsc) {
|
|
freezeDscOnSpan(r95, dsc);
|
|
r48 = r95;
|
|
}
|
|
}
|
|
logSpanStart(r48);
|
|
setCapturedScopesOnSpan(r48, scope, isolationScope);
|
|
return r48;
|
|
}
|
|
return new SentryNonRecordingSpan();
|
|
};
|
|
_startRootSpan = function _startRootSpan(a0, a1, a2) {
|
|
const client = getClient();
|
|
const r10 = client && client.getOptions() || {};
|
|
const { name: name2 = "", attributes } = a0;
|
|
const [sampled, r36] = a1.getScopeData().sdkProcessingMetadata[c4100_3] ? [false] : sampleSpan(r10, {
|
|
name: name2,
|
|
parentSampled: a2,
|
|
attributes,
|
|
transactionContext: {
|
|
name: name2,
|
|
parentSampled: a2
|
|
}
|
|
});
|
|
const attributes2 = {};
|
|
attributes2[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = "custom";
|
|
HermesBuiltin.copyDataProperties(attributes2, a0.attributes);
|
|
const sentrySpan = new SentrySpan({
|
|
...a0,
|
|
attributes: attributes2,
|
|
sampled
|
|
});
|
|
if (r36 !== void 0) {
|
|
sentrySpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, r36);
|
|
}
|
|
if (client) {
|
|
client.emit("spanStart", sentrySpan);
|
|
}
|
|
return sentrySpan;
|
|
};
|
|
c4100_3 = "__SENTRY_SUPPRESS_TRACING__";
|
|
export const continueTrace = (a0, a1) => {
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
if (asyncContextStrategy.continueTrace) {
|
|
return asyncContextStrategy.continueTrace(a0, a1);
|
|
}
|
|
const { sentryTrace, baggage } = a0;
|
|
return withScope((a0) => {
|
|
a0.setPropagationContext(propagationContextFromHeaders(sentryTrace, baggage));
|
|
return a1();
|
|
});
|
|
};
|
|
export function startInactiveSpan(a0) {
|
|
let c15705_0 = a0;
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
if (asyncContextStrategy.startInactiveSpan) {
|
|
return asyncContextStrategy.startInactiveSpan(a0);
|
|
}
|
|
const r9 = {
|
|
isStandalone: (a0.experimental || {}).standalone,
|
|
...a0
|
|
};
|
|
const startTime = a0.startTime;
|
|
let r23 = r9;
|
|
if (startTime) {
|
|
const r24 = {
|
|
...r9,
|
|
startTimestamp: spanTimeInputToSeconds(a0.startTime)
|
|
};
|
|
delete r24["startTime"];
|
|
r23 = r24;
|
|
}
|
|
const spanArguments = r23;
|
|
const { forceTransaction, parentSpan } = a0;
|
|
return (a0.scope ? (a0) => withScope(c15705_0.scope, a0) : parentSpan !== void 0 ? (a0) => {
|
|
let env25848;
|
|
const r9 = env25848 = {
|
|
$parent: env4100
|
|
};
|
|
env25848[0] = parentSpan;
|
|
env25848[1] = a0;
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
return asyncContextStrategy.withActiveSpan ? asyncContextStrategy.withActiveSpan(parentSpan, a0) : withScope($mk78495(r9));
|
|
} : (a0) => a0())(() => {
|
|
const currentScope = getCurrentScope();
|
|
const r9 = _getSpanForScope(currentScope);
|
|
let parentSpan4 = void 0;
|
|
if (r9) {
|
|
const client = getClient();
|
|
parentSpan4 = (client ? client.getOptions() : {}).parentSpanIsAlwaysRootSpan ? getRootSpan(r9) : r9;
|
|
}
|
|
return c15705_0.onlyIfParent && !parentSpan4 ? new SentryNonRecordingSpan() : createChildOrRootSpan({
|
|
parentSpan: parentSpan4,
|
|
spanArguments,
|
|
forceTransaction,
|
|
scope: currentScope
|
|
});
|
|
});
|
|
}
|
|
export function startNewTrace(c15706_0) {
|
|
return withScope((a0) => {
|
|
const setPropagationContext = a0.setPropagationContext;
|
|
const r2 = env4100;
|
|
setPropagationContext.call(a0, {
|
|
traceId: generateTraceId()
|
|
});
|
|
if (DEBUG_BUILD) {
|
|
logger.info(`Starting a new trace with id ${a0.getPropagationContext().traceId}`);
|
|
}
|
|
let env25849;
|
|
const r31 = env25849 = {
|
|
$parent: r2
|
|
};
|
|
env25849[0] = null;
|
|
env25849[1] = c15706_0;
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
return asyncContextStrategy.withActiveSpan ? asyncContextStrategy.withActiveSpan(null, c15706_0) : withScope($mk78495(r31));
|
|
});
|
|
}
|
|
export function startSpan(a0, a1) {
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
if (asyncContextStrategy.startSpan) {
|
|
return asyncContextStrategy.startSpan(a0, a1);
|
|
}
|
|
const r10 = {
|
|
isStandalone: (a0.experimental || {}).standalone,
|
|
...a0
|
|
};
|
|
const startTime = a0.startTime;
|
|
let r26 = r10;
|
|
if (startTime) {
|
|
const r27 = {
|
|
...r10,
|
|
startTimestamp: spanTimeInputToSeconds(a0.startTime)
|
|
};
|
|
delete r27["startTime"];
|
|
r26 = r27;
|
|
}
|
|
const spanArguments2 = r26;
|
|
const { forceTransaction: forceTransaction2, parentSpan: parentSpan2 } = a0;
|
|
return withScope(a0.scope, () => {
|
|
let env25850;
|
|
const r4 = env25850 = {
|
|
$parent: env4100
|
|
};
|
|
env25850[0] = parentSpan2;
|
|
return (parentSpan2 !== void 0 ? $mk78496(r4) : $mk78497())(() => {
|
|
const currentScope = getCurrentScope();
|
|
const r9 = _getSpanForScope(currentScope);
|
|
let parentSpan4 = void 0;
|
|
if (r9) {
|
|
const client = getClient();
|
|
parentSpan4 = (client ? client.getOptions() : {}).parentSpanIsAlwaysRootSpan ? getRootSpan(r9) : r9;
|
|
}
|
|
const r36 = a0.onlyIfParent && !parentSpan4 ? new SentryNonRecordingSpan() : createChildOrRootSpan({
|
|
parentSpan: parentSpan4,
|
|
spanArguments: spanArguments2,
|
|
forceTransaction: forceTransaction2,
|
|
scope: currentScope
|
|
});
|
|
let c29765_0 = r36;
|
|
_setSpanForScope(currentScope, r36);
|
|
return handleCallbackErrors(() => a1(c29765_0), () => {
|
|
const status = spanToJSON(c29765_0).status;
|
|
const isRecording = c29765_0.isRecording();
|
|
if (!(isRecording ? status && status !== "ok" : !isRecording)) {
|
|
c29765_0.setStatus({
|
|
code: SPAN_STATUS_ERROR,
|
|
message: "internal_error"
|
|
});
|
|
}
|
|
}, () => c29765_0.end());
|
|
});
|
|
});
|
|
}
|
|
export function startSpanManual(a0, a1) {
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
if (asyncContextStrategy.startSpanManual) {
|
|
return asyncContextStrategy.startSpanManual(a0, a1);
|
|
}
|
|
const r10 = {
|
|
isStandalone: (a0.experimental || {}).standalone,
|
|
...a0
|
|
};
|
|
const startTime = a0.startTime;
|
|
let r26 = r10;
|
|
if (startTime) {
|
|
const r27 = {
|
|
...r10,
|
|
startTimestamp: spanTimeInputToSeconds(a0.startTime)
|
|
};
|
|
delete r27["startTime"];
|
|
r26 = r27;
|
|
}
|
|
const spanArguments3 = r26;
|
|
const { forceTransaction: forceTransaction3, parentSpan: parentSpan3 } = a0;
|
|
return withScope(a0.scope, () => {
|
|
let env25851;
|
|
const r4 = env25851 = {
|
|
$parent: env4100
|
|
};
|
|
env25851[0] = parentSpan3;
|
|
return (parentSpan3 !== void 0 ? $mk78496(r4) : $mk78497())(() => {
|
|
let c29766_0;
|
|
const finishAndSetSpan2 = function finishAndSetSpan() {
|
|
c29766_0.end();
|
|
};
|
|
const currentScope = getCurrentScope();
|
|
const r10 = _getSpanForScope(currentScope);
|
|
let parentSpan4 = void 0;
|
|
if (r10) {
|
|
const client = getClient();
|
|
parentSpan4 = (client ? client.getOptions() : {}).parentSpanIsAlwaysRootSpan ? getRootSpan(r10) : r10;
|
|
}
|
|
const r37 = a0.onlyIfParent && !parentSpan4 ? new SentryNonRecordingSpan() : createChildOrRootSpan({
|
|
parentSpan: parentSpan4,
|
|
spanArguments: spanArguments3,
|
|
forceTransaction: forceTransaction3,
|
|
scope: currentScope
|
|
});
|
|
c29766_0 = r37;
|
|
_setSpanForScope(currentScope, r37);
|
|
return handleCallbackErrors(() => a1(c29766_0, finishAndSetSpan2), () => {
|
|
const status = spanToJSON(c29766_0).status;
|
|
const isRecording = c29766_0.isRecording();
|
|
if (!(isRecording ? status && status !== "ok" : !isRecording)) {
|
|
c29766_0.setStatus({
|
|
code: SPAN_STATUS_ERROR,
|
|
message: "internal_error"
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
export function suppressTracing(a0) {
|
|
let c15709_0 = a0;
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
return asyncContextStrategy.suppressTracing ? asyncContextStrategy.suppressTracing(a0) : withScope((a0) => {
|
|
const setSDKProcessingMetadata = a0.setSDKProcessingMetadata;
|
|
const r1 = {};
|
|
r1[c4100_3] = true;
|
|
setSDKProcessingMetadata.call(a0, r1);
|
|
return c15709_0();
|
|
});
|
|
}
|
|
export function withActiveSpan(a0, a1) {
|
|
let env15703;
|
|
const r1 = env15703 = {
|
|
$parent: env4100
|
|
};
|
|
env15703[0] = a0;
|
|
env15703[1] = a1;
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
return asyncContextStrategy.withActiveSpan ? asyncContextStrategy.withActiveSpan(a0, a1) : withScope($mk78495(r1));
|
|
}
|