437 lines
15 KiB
JavaScript
437 lines
15 KiB
JavaScript
// Metro module 866 (f867).
|
|
import { getIsolationScope, getClient, withScope, getCurrentScope } from "./Module848";
|
|
import { SentryNonRecordingSpan } from "./SentryNonRecordingSpan";
|
|
import { _setSpanForScope, _getSpanForScope } from "./Module844";
|
|
import { handleCallbackErrors } from "./Module867";
|
|
import { spanIsSampled, addChildSpanToSpan, spanTimeInputToSeconds, getRootSpan, spanToJSON } from "./spanToJSON";
|
|
import { SPAN_STATUS_ERROR } from "./Module840";
|
|
import { getMainCarrier } from "./Module825";
|
|
import { getAsyncContextStrategy } from "./Module841";
|
|
import { baggageHeaderToDynamicSamplingContext } from "./Module835";
|
|
import { shouldContinueTrace, propagationContextFromHeaders } from "./Module834";
|
|
import { DEBUG_BUILD } from "./Module823";
|
|
import { debug } from "./consoleSandbox";
|
|
import { hasSpansEnabled } from "./Module855";
|
|
import { getDynamicSamplingContextFromSpan, freezeDscOnSpan } from "./getDynamicSamplingContextFromSpan";
|
|
import { logSpanStart } from "./Module861";
|
|
import { setCapturedScopesOnSpan } from "./unwrapScopeFromWeakRef";
|
|
import { sampleSpan } from "./Module868";
|
|
import { parseSampleRate } from "./Module836";
|
|
import { SentrySpan } from "./isFullFinishedSpan";
|
|
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE } from "./Module839";
|
|
import { HermesBuiltin } from "../_hermes/prelude";
|
|
function $mk67199($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 $mk67200($env) {
|
|
return (a0) => {
|
|
const setPropagationContext = a0.setPropagationContext;
|
|
const r2 = $env.$parent;
|
|
const r6 = r2[0];
|
|
const r3 = r2[1];
|
|
setPropagationContext.call(a0, {
|
|
traceId: r6(r3[11]).generateTraceId(),
|
|
sampleRand: r6(r3[12]).safeMathRandom()
|
|
});
|
|
if (r6(r3[13]).DEBUG_BUILD) {
|
|
r6(r3[14]).debug.log(`Starting a new trace with id ${a0.getPropagationContext().traceId}`);
|
|
}
|
|
let env23859;
|
|
const r34 = $env[0];
|
|
const r35 = env23859 = {
|
|
$parent: r2
|
|
};
|
|
env23859[0] = null;
|
|
env23859[1] = r34;
|
|
const mainCarrier = r6(r3[7]).getMainCarrier();
|
|
const asyncContextStrategy = r6(r3[8]).getAsyncContextStrategy(mainCarrier);
|
|
return asyncContextStrategy.withActiveSpan ? asyncContextStrategy.withActiveSpan(null, r34) : r6(r3[1]).withScope($mk67199(r35));
|
|
};
|
|
}
|
|
function $mk67201($env) {
|
|
return (a0) => {
|
|
let env23860;
|
|
const r2 = $env.$parent;
|
|
const r4 = $env[0];
|
|
const r9 = env23860 = {
|
|
$parent: r2
|
|
};
|
|
env23860[0] = r4;
|
|
env23860[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($mk67199(r9));
|
|
};
|
|
}
|
|
function $mk67202() {
|
|
return (a0) => a0();
|
|
}
|
|
let _startRootSpan, c706_3;
|
|
let env706 = {};
|
|
const createChildOrRootSpan = function createChildOrRootSpan({ parentSpan: parentSpan4, spanArguments: spanArguments4, forceTransaction: forceTransaction4, scope }) {
|
|
let r59;
|
|
if (hasSpansEnabled()) {
|
|
const isolationScope = getIsolationScope();
|
|
if (parentSpan4 && !forceTransaction4) {
|
|
const r41 = parentSpan4.spanContext();
|
|
const { spanId, traceId } = r41;
|
|
const r46 = scope.getScopeData().sdkProcessingMetadata[c706_3];
|
|
const sampled = r46 ? !r46 : spanIsSampled(parentSpan4);
|
|
r59 = sampled ? new SentrySpan({
|
|
...spanArguments4,
|
|
parentSpanId: spanId,
|
|
traceId,
|
|
sampled
|
|
}) : new SentryNonRecordingSpan({
|
|
traceId
|
|
});
|
|
addChildSpanToSpan(parentSpan4, r59);
|
|
const client = getClient();
|
|
if (client) {
|
|
client.emit("spanStart", r59);
|
|
if (spanArguments4.endTimestamp) {
|
|
client.emit("spanEnd", r59);
|
|
}
|
|
}
|
|
addChildSpanToSpan(parentSpan4, r59);
|
|
} else if (parentSpan4) {
|
|
const dynamicSamplingContextFromSpan = getDynamicSamplingContextFromSpan(parentSpan4);
|
|
const r117 = parentSpan4.spanContext();
|
|
const r129 = _startRootSpan({
|
|
traceId: r117.traceId,
|
|
parentSpanId: r117.spanId,
|
|
...spanArguments4
|
|
}, scope, spanIsSampled(parentSpan4));
|
|
freezeDscOnSpan(r129, dynamicSamplingContextFromSpan);
|
|
r59 = r129;
|
|
} else {
|
|
const r89 = {
|
|
...isolationScope.getPropagationContext(),
|
|
...scope.getPropagationContext()
|
|
};
|
|
const { traceId: traceId2, dsc } = r89;
|
|
const r107 = _startRootSpan({
|
|
traceId: traceId2,
|
|
parentSpanId: r89.parentSpanId,
|
|
...spanArguments4
|
|
}, scope, r89.sampled);
|
|
r59 = r107;
|
|
if (dsc) {
|
|
freezeDscOnSpan(r107, dsc);
|
|
r59 = r107;
|
|
}
|
|
}
|
|
logSpanStart(r59);
|
|
setCapturedScopesOnSpan(r59, scope, isolationScope);
|
|
return r59;
|
|
}
|
|
const sentryNonRecordingSpan = new SentryNonRecordingSpan();
|
|
if (!(!forceTransaction4 && parentSpan4)) {
|
|
freezeDscOnSpan(sentryNonRecordingSpan, {
|
|
sampled: "false",
|
|
sample_rate: "0",
|
|
transaction: spanArguments4.name,
|
|
...getDynamicSamplingContextFromSpan(sentryNonRecordingSpan)
|
|
});
|
|
}
|
|
return sentryNonRecordingSpan;
|
|
};
|
|
_startRootSpan = function _startRootSpan(a0, a1, a2) {
|
|
const client = getClient();
|
|
const r14 = (client == null ? void 0 : client.getOptions()) || {};
|
|
const name = a0.name;
|
|
const spanName = name !== void 0 ? name : "";
|
|
const r27 = {
|
|
spanAttributes: {
|
|
...a0.attributes
|
|
},
|
|
spanName,
|
|
parentSampled: a2
|
|
};
|
|
if (client != null) {
|
|
client.emit("beforeSampling", r27, {
|
|
decision: false
|
|
});
|
|
}
|
|
let parentSampled = r27.parentSampled;
|
|
if (parentSampled == null) {
|
|
parentSampled = a2;
|
|
}
|
|
const spanAttributes = r27.spanAttributes;
|
|
const propagationContext = a1.getPropagationContext();
|
|
const [sampled, r56, r57] = a1.getScopeData().sdkProcessingMetadata[c706_3] ? [false] : sampleSpan(r14, {
|
|
name: spanName,
|
|
parentSampled,
|
|
attributes: spanAttributes,
|
|
parentSampleRate: parseSampleRate(propagationContext.dsc?.sample_rate)
|
|
}, propagationContext.sampleRand);
|
|
const attributes = {};
|
|
attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = "custom";
|
|
attributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] = r56 !== void 0 ? r57 ? r56 : void 0 : void 0;
|
|
HermesBuiltin.copyDataProperties(attributes, spanAttributes);
|
|
const sentrySpan = new SentrySpan({
|
|
...a0,
|
|
attributes,
|
|
sampled
|
|
});
|
|
if (sampled ? !sampled : client) {
|
|
if (DEBUG_BUILD) {
|
|
debug.log("[Tracing] Discarding root span because its trace was not chosen to be sampled.");
|
|
}
|
|
client.recordDroppedEvent("sample_rate", "transaction");
|
|
}
|
|
if (client) {
|
|
client.emit("spanStart", sentrySpan);
|
|
}
|
|
return sentrySpan;
|
|
};
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
c706_3 = "__SENTRY_SUPPRESS_TRACING__";
|
|
export const continueTrace = (a0, a1) => {
|
|
let r38;
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
if (asyncContextStrategy.continueTrace) {
|
|
return asyncContextStrategy.continueTrace(a0, a1);
|
|
}
|
|
const { sentryTrace, baggage } = a0;
|
|
const client = getClient();
|
|
const r12 = baggageHeaderToDynamicSamplingContext(baggage);
|
|
if (client && !shouldContinueTrace(client, r12?.org_id)) {
|
|
let env12521;
|
|
const r33 = env12521 = {
|
|
$parent: env706
|
|
};
|
|
env12521[0] = a1;
|
|
r38 = withScope($mk67200(r33));
|
|
} else {
|
|
r38 = withScope((a0) => {
|
|
a0.setPropagationContext(propagationContextFromHeaders(sentryTrace, baggage));
|
|
_setSpanForScope(a0, void 0);
|
|
return a1();
|
|
});
|
|
}
|
|
return r38;
|
|
};
|
|
export function startInactiveSpan(a0) {
|
|
let c12522_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(c12522_0.scope, a0) : parentSpan !== void 0 ? (a0) => {
|
|
let env23861;
|
|
const r9 = env23861 = {
|
|
$parent: env706
|
|
};
|
|
env23861[0] = parentSpan;
|
|
env23861[1] = a0;
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
return asyncContextStrategy.withActiveSpan ? asyncContextStrategy.withActiveSpan(parentSpan, a0) : withScope($mk67199(r9));
|
|
} : (a0) => a0())(() => {
|
|
const currentScope = getCurrentScope();
|
|
let parentSpan4 = parentSpan;
|
|
if (!parentSpan) {
|
|
parentSpan4 = void 0;
|
|
if (parentSpan !== null) {
|
|
const r11 = _getSpanForScope(currentScope);
|
|
parentSpan4 = void 0;
|
|
if (r11) {
|
|
const client = getClient();
|
|
parentSpan4 = (client ? client.getOptions() : {}).parentSpanIsAlwaysRootSpan ? getRootSpan(r11) : r11;
|
|
}
|
|
}
|
|
}
|
|
return c12522_0.onlyIfParent && !parentSpan4 ? new SentryNonRecordingSpan() : createChildOrRootSpan({
|
|
parentSpan: parentSpan4,
|
|
spanArguments,
|
|
forceTransaction,
|
|
scope: currentScope
|
|
});
|
|
});
|
|
}
|
|
export function startNewTrace(a0) {
|
|
let env12519;
|
|
const r1 = env12519 = {
|
|
$parent: env706
|
|
};
|
|
env12519[0] = a0;
|
|
return withScope($mk67200(r1));
|
|
}
|
|
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, scope } = a0;
|
|
return withScope(scope == null ? void 0 : scope.clone(), () => {
|
|
let env23862;
|
|
const r4 = env23862 = {
|
|
$parent: env706
|
|
};
|
|
env23862[0] = parentSpan2;
|
|
return (parentSpan2 !== void 0 ? $mk67201(r4) : $mk67202())(() => {
|
|
const currentScope = getCurrentScope();
|
|
let parentSpan4 = parentSpan2;
|
|
if (!parentSpan2) {
|
|
parentSpan4 = void 0;
|
|
if (parentSpan2 !== null) {
|
|
const r11 = _getSpanForScope(currentScope);
|
|
parentSpan4 = void 0;
|
|
if (r11) {
|
|
const client = getClient();
|
|
parentSpan4 = (client ? client.getOptions() : {}).parentSpanIsAlwaysRootSpan ? getRootSpan(r11) : r11;
|
|
}
|
|
}
|
|
}
|
|
const r38 = a0.onlyIfParent && !parentSpan4 ? new SentryNonRecordingSpan() : createChildOrRootSpan({
|
|
parentSpan: parentSpan4,
|
|
spanArguments: spanArguments2,
|
|
forceTransaction: forceTransaction2,
|
|
scope: currentScope
|
|
});
|
|
let c28674_0 = r38;
|
|
_setSpanForScope(currentScope, r38);
|
|
return handleCallbackErrors(() => a1(c28674_0), () => {
|
|
const status = spanToJSON(c28674_0).status;
|
|
const isRecording = c28674_0.isRecording();
|
|
if (!(isRecording ? status && status !== "ok" : !isRecording)) {
|
|
c28674_0.setStatus({
|
|
code: SPAN_STATUS_ERROR,
|
|
message: "internal_error"
|
|
});
|
|
}
|
|
}, () => {
|
|
c28674_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, scope } = a0;
|
|
return withScope(scope == null ? void 0 : scope.clone(), () => {
|
|
let env23863;
|
|
const r4 = env23863 = {
|
|
$parent: env706
|
|
};
|
|
env23863[0] = parentSpan3;
|
|
return (parentSpan3 !== void 0 ? $mk67201(r4) : $mk67202())(() => {
|
|
const currentScope = getCurrentScope();
|
|
let parentSpan4 = parentSpan3;
|
|
if (!parentSpan3) {
|
|
parentSpan4 = void 0;
|
|
if (parentSpan3 !== null) {
|
|
const r11 = _getSpanForScope(currentScope);
|
|
parentSpan4 = void 0;
|
|
if (r11) {
|
|
const client = getClient();
|
|
parentSpan4 = (client ? client.getOptions() : {}).parentSpanIsAlwaysRootSpan ? getRootSpan(r11) : r11;
|
|
}
|
|
}
|
|
}
|
|
const r37 = a0.onlyIfParent && !parentSpan4 ? new SentryNonRecordingSpan() : createChildOrRootSpan({
|
|
parentSpan: parentSpan4,
|
|
spanArguments: spanArguments3,
|
|
forceTransaction: forceTransaction3,
|
|
scope: currentScope
|
|
});
|
|
let c28675_0 = r37;
|
|
_setSpanForScope(currentScope, r37);
|
|
return handleCallbackErrors(() => a1(c28675_0, () => c28675_0.end()), () => {
|
|
const status = spanToJSON(c28675_0).status;
|
|
const isRecording = c28675_0.isRecording();
|
|
if (!(isRecording ? status && status !== "ok" : !isRecording)) {
|
|
c28675_0.setStatus({
|
|
code: SPAN_STATUS_ERROR,
|
|
message: "internal_error"
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
export function suppressTracing(a0) {
|
|
let c12525_0 = a0;
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
return asyncContextStrategy.suppressTracing ? asyncContextStrategy.suppressTracing(a0) : withScope((a0) => {
|
|
const setSDKProcessingMetadata = a0.setSDKProcessingMetadata;
|
|
const r1 = {};
|
|
r1[c706_3] = true;
|
|
setSDKProcessingMetadata.call(a0, r1);
|
|
const r10 = c12525_0();
|
|
const setSDKProcessingMetadata2 = a0.setSDKProcessingMetadata;
|
|
const r12 = {};
|
|
r12[c706_3] = void 0;
|
|
setSDKProcessingMetadata2.call(a0, r12);
|
|
return r10;
|
|
});
|
|
}
|
|
export function withActiveSpan(a0, a1) {
|
|
let env12518;
|
|
const r1 = env12518 = {
|
|
$parent: env706
|
|
};
|
|
env12518[0] = a0;
|
|
env12518[1] = a1;
|
|
const asyncContextStrategy = getAsyncContextStrategy(getMainCarrier());
|
|
return asyncContextStrategy.withActiveSpan ? asyncContextStrategy.withActiveSpan(a0, a1) : withScope($mk67199(r1));
|
|
}
|