decord/source/7386_sampleSpan.js

67 lines
2.4 KiB
JavaScript
Raw Normal View History

2026-08-05 07:35:12 +00:00
// Module ID: 7386
// Function ID: 7387
2026-07-29 08:29:29 +00:00
// Name: sampleSpan
2026-08-05 07:35:12 +00:00
// Dependencies: [7379, 7374, 7387, 7375, 7347]
2026-07-29 08:29:29 +00:00
2026-08-05 07:35:12 +00:00
// Module 7386 (sampleSpan)
2026-07-29 08:29:29 +00:00
const require = arg1;
const dependencyMap = arg6;
arg5.sampleSpan = function sampleSpan(tracesSampler, normalizedRequest) {
2026-08-05 07:35:12 +00:00
let obj = require(7379) /* hasTracingEnabled */;
2026-07-29 08:29:29 +00:00
if (obj.hasTracingEnabled(tracesSampler)) {
2026-08-05 07:35:12 +00:00
let tmpResult = tmp(7374);
2026-07-29 08:29:29 +00:00
const isolationScope = tmpResult.getIsolationScope();
obj = {};
const merged = Object.assign(normalizedRequest);
obj.normalizedRequest = normalizedRequest.normalizedRequest || isolationScope.getScopeData().sdkProcessingMetadata.normalizedRequest;
2026-08-04 21:03:28 +00:00
if (typeof tracesSampler.tracesSampler === "function") {
2026-07-29 08:29:29 +00:00
let num = tracesSampler.tracesSampler(obj);
} else if (undefined !== obj.parentSampled) {
num = obj.parentSampled;
} else {
num = 1;
if (undefined !== tracesSampler.tracesSampleRate) {
num = tracesSampler.tracesSampleRate;
}
}
2026-08-05 07:35:12 +00:00
tmpResult = tmp(7387);
2026-07-29 08:29:29 +00:00
const parseSampleRateResult = tmpResult.parseSampleRate(num);
if (undefined === parseSampleRateResult) {
2026-08-05 07:35:12 +00:00
if (tmp(7375).DEBUG_BUILD) {
const logger3 = tmp(7347).logger;
2026-07-29 08:29:29 +00:00
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 {
2026-08-05 07:35:12 +00:00
if (tmp(7375).DEBUG_BUILD) {
const logger2 = tmp(7347).logger;
2026-07-29 08:29:29 +00:00
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 {
2026-08-05 07:35:12 +00:00
if (tmp(7375).DEBUG_BUILD) {
const logger = tmp(7347).logger;
2026-07-29 08:29:29 +00:00
let str = "a negative sampling decision was inherited or tracesSampleRate is set to 0";
2026-08-04 21:03:28 +00:00
if (typeof tracesSampler.tracesSampler === "function") {
2026-07-29 08:29:29 +00:00
str = "tracesSampler returned 0 or false";
}
logger.log(`[Tracing] Discarding transaction because ${str}`);
}
items3 = [false, parseSampleRateResult];
}
return items3;
} else {
const items4 = [false];
return items4;
}
};