decord/source/7815_sampleSpan.js
2026-08-24 06:08:38 +00:00

68 lines
2.5 KiB
JavaScript

// Module ID: 7815
// Function ID: 7816
// Name: sampleSpan
// Dependencies: [7808, 7803, 7816, 7804, 7776]
// Module 7815 (sampleSpan)
import hasTracingEnabled from "hasTracingEnabled" /* 7808 */;
require = arg1;
const dependencyMap = arg6;
arg5.sampleSpan = function sampleSpan(tracesSampler, normalizedRequest) {
let obj = hasTracingEnabled;
if (obj.hasTracingEnabled(tracesSampler)) {
let tmpResult = tmp(7803);
const isolationScope = tmpResult.getIsolationScope();
obj = {};
const merged = Object.assign(normalizedRequest);
obj.normalizedRequest = normalizedRequest.normalizedRequest || isolationScope.getScopeData().sdkProcessingMetadata.normalizedRequest;
if (typeof tracesSampler.tracesSampler === "function") {
let num = tracesSampler.tracesSampler(obj);
} else if (undefined !== obj.parentSampled) {
num = obj.parentSampled;
} else {
num = 1;
if (undefined !== tracesSampler.tracesSampleRate) {
num = tracesSampler.tracesSampleRate;
}
}
tmpResult = tmp(7816);
const parseSampleRateResult = tmpResult.parseSampleRate(num);
if (undefined === parseSampleRateResult) {
if (tmp(7804).DEBUG_BUILD) {
const logger3 = tmp(7776).logger;
logger3.warn("[Tracing] Discarding transaction because of invalid sample rate.");
}
const items = [false];
let items3 = items;
} else if (parseSampleRateResult) {
const _Math = Math;
if (Math.random() < parseSampleRateResult) {
const items1 = [true, parseSampleRateResult];
let items2 = items1;
} else {
if (tmp(7804).DEBUG_BUILD) {
const logger2 = tmp(7776).logger;
const _Number = Number;
const _HermesInternal = HermesInternal;
logger2.log("[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = " + Number(num) + ")");
}
items2 = [false, parseSampleRateResult];
}
} else {
if (tmp(7804).DEBUG_BUILD) {
const logger = tmp(7776).logger;
let str = "a negative sampling decision was inherited or tracesSampleRate is set to 0";
if (typeof tracesSampler.tracesSampler === "function") {
str = "tracesSampler returned 0 or false";
}
logger.log(`[Tracing] Discarding transaction because ${str}`);
}
items3 = [false, parseSampleRateResult];
}
return items3;
} else {
const items4 = [false];
return items4;
}
};