51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
// Metro module 868 (f869).
|
|
import { hasSpansEnabled } from "./Module855";
|
|
import { parseSampleRate } from "./Module836";
|
|
import { DEBUG_BUILD } from "./Module823";
|
|
import { debug } from "./consoleSandbox";
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
export function sampleSpan(a0, a1, a2) {
|
|
let r25, r26;
|
|
if (hasSpansEnabled(a0)) {
|
|
if (typeof a0.tracesSampler === "function") {
|
|
r26 = a0.tracesSampler.call(a0, {
|
|
...a1,
|
|
inheritOrSampleWith: (a0) => typeof a1.parentSampleRate === "number" ? a1.parentSampleRate : typeof a1.parentSampled === "boolean" ? Number(a1.parentSampled) : a0
|
|
});
|
|
r25 = true;
|
|
} else if (a1.parentSampled !== void 0) {
|
|
r26 = a1.parentSampled;
|
|
r25 = void 0;
|
|
} else {
|
|
const tracesSampleRate = a0.tracesSampleRate;
|
|
r25 = void 0;
|
|
r26 = void 0;
|
|
if (tracesSampleRate !== void 0) {
|
|
r26 = a0.tracesSampleRate;
|
|
r25 = true;
|
|
}
|
|
}
|
|
const r33 = parseSampleRate(r26);
|
|
if (r33 === void 0) {
|
|
if (DEBUG_BUILD) {
|
|
debug.warn(`[Tracing] Discarding root span because of invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(r26)} of type ${JSON.stringify(typeof r26)}.`);
|
|
}
|
|
return [false];
|
|
}
|
|
if (r33) {
|
|
const r48 = a2 < r33;
|
|
if (!r48 && DEBUG_BUILD) {
|
|
debug.log(`[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = ${Number(r26)})`);
|
|
}
|
|
return [r48, r33, r25];
|
|
}
|
|
if (DEBUG_BUILD) {
|
|
debug.log("[Tracing] Discarding transaction because " + (typeof a0.tracesSampler === "function" ? "tracesSampler returned 0 or false" : "a negative sampling decision was inherited or tracesSampleRate is set to 0"));
|
|
}
|
|
return [false, r33, r25];
|
|
}
|
|
return [false];
|
|
}
|