decord/source/833_getDynamicSamplingContextFromClient.js

129 lines
5 KiB
JavaScript
Raw Normal View History

2026-07-20 16:05:17 +00:00
// Module ID: 833
2026-07-23 10:11:24 +00:00
// Function ID: 9278
2026-07-20 16:05:17 +00:00
// Name: getDynamicSamplingContextFromClient
2026-07-23 10:11:24 +00:00
// Dependencies: [799, 834, 814, 825, 796, 816, 812, 831, 797]
2026-07-20 16:05:17 +00:00
// Module 833 (getDynamicSamplingContextFromClient)
2026-07-23 10:11:24 +00:00
let require = arg1;
const dependencyMap = arg6;
2026-07-20 16:05:17 +00:00
function getDynamicSamplingContextFromClient(trace_id, getOptions) {
const options = getOptions.getOptions();
const obj = {};
let DEFAULT_ENVIRONMENT = options.environment;
if (!DEFAULT_ENVIRONMENT) {
2026-07-23 10:11:24 +00:00
DEFAULT_ENVIRONMENT = require(834).DEFAULT_ENVIRONMENT;
2026-07-20 16:05:17 +00:00
}
obj.environment = DEFAULT_ENVIRONMENT;
obj.release = options.release;
obj.public_key = getOptions.getDsn() || {}.publicKey;
obj.trace_id = trace_id;
const tmp2 = getOptions.getDsn() || {};
2026-07-23 10:11:24 +00:00
obj.org_id = require(814) /* dsnFromString */.extractOrgIdFromClient(getOptions);
2026-07-20 16:05:17 +00:00
getOptions.emit("createDsc", obj);
return obj;
}
function getDynamicSamplingContextFromSpan(spanContext) {
function applyLocalSampleRateToDsc(result1) {
2026-07-23 10:11:24 +00:00
let tmp = "number" !== typeof closure_0;
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-07-23 10:11:24 +00:00
tmp = "string" !== typeof closure_0;
2026-07-20 16:05:17 +00:00
}
if (!tmp) {
const _HermesInternal = HermesInternal;
2026-07-23 10:11:24 +00:00
result1.sample_rate = "" + closure_0;
2026-07-20 16:05:17 +00:00
}
return result1;
}
2026-07-23 10:11:24 +00:00
const client = require(825) /* getCurrentScope */.getClient();
2026-07-20 16:05:17 +00:00
if (client) {
2026-07-23 10:11:24 +00:00
const rootSpan = require(796) /* convertSpanLinksForEnvelope */.getRootSpan(spanContext);
const obj3 = require(796) /* convertSpanLinksForEnvelope */;
const spanToJSONResult = require(796) /* convertSpanLinksForEnvelope */.spanToJSON(rootSpan);
2026-07-20 16:05:17 +00:00
const data = spanToJSONResult.data;
const traceState = rootSpan.spanContext().traceState;
let value;
if (null != traceState) {
let str = "sentry.sample_rate";
value = traceState.get("sentry.sample_rate");
}
if (null == value) {
2026-07-23 10:11:24 +00:00
value = data[require(undefined, 816).SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];
2026-07-20 16:05:17 +00:00
}
if (null == value) {
2026-07-23 10:11:24 +00:00
value = data[require(undefined, 816).SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE];
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
require = value;
if (rootSpan[_frozenDsc]) {
2026-07-20 16:05:17 +00:00
const result = applyLocalSampleRateToDsc(tmp11);
return tmp11;
} else {
value = undefined;
if (null != traceState) {
value = traceState.get("sentry.dsc");
}
let result1 = value;
if (value) {
2026-07-23 10:11:24 +00:00
result1 = require(812) /* parseBaggageHeader */.baggageHeaderToDynamicSamplingContext(value);
const obj6 = require(812) /* parseBaggageHeader */;
2026-07-20 16:05:17 +00:00
}
if (result1) {
const result2 = applyLocalSampleRateToDsc(result1);
return result1;
} else {
const tmp17 = getDynamicSamplingContextFromClient(spanContext.spanContext().traceId, client);
const description = spanToJSONResult.description;
if (tmp20) {
tmp17.transaction = description;
}
2026-07-23 10:11:24 +00:00
tmp20 = "url" !== data[require(undefined, 816).SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] && description;
2026-07-20 16:05:17 +00:00
if (obj7.hasSpansEnabled()) {
const _String = String;
2026-07-23 10:11:24 +00:00
tmp17.sampled = String(require(796) /* convertSpanLinksForEnvelope */.spanIsSampled(rootSpan));
2026-07-20 16:05:17 +00:00
let value1;
if (null != traceState) {
value1 = traceState.get("sentry.sample_rand");
}
if (null == value1) {
2026-07-23 10:11:24 +00:00
const scope = require(797) /* unwrapScopeFromWeakRef */.getCapturedScopesOnSpan(rootSpan).scope;
2026-07-20 16:05:17 +00:00
str = undefined;
if (null != scope) {
str = scope.getPropagationContext().sampleRand.toString();
const str5 = scope.getPropagationContext().sampleRand;
}
value1 = str;
2026-07-23 10:11:24 +00:00
const obj9 = require(797) /* unwrapScopeFromWeakRef */;
2026-07-20 16:05:17 +00:00
}
tmp17.sample_rand = value1;
2026-07-23 10:11:24 +00:00
const obj8 = require(796) /* convertSpanLinksForEnvelope */;
2026-07-20 16:05:17 +00:00
}
const result3 = applyLocalSampleRateToDsc(tmp17);
client.emit("createDsc", tmp17, rootSpan);
return tmp17;
}
}
2026-07-23 10:11:24 +00:00
const obj5 = require(796) /* convertSpanLinksForEnvelope */;
2026-07-20 16:05:17 +00:00
} else {
return {};
}
2026-07-23 10:11:24 +00:00
const obj = require(825) /* getCurrentScope */;
2026-07-20 16:05:17 +00:00
}
Object.defineProperty(arg5, Symbol.toStringTag, { value: "Module" });
2026-07-23 10:11:24 +00:00
const _frozenDsc = "_frozenDsc";
2026-07-20 16:05:17 +00:00
arg5.freezeDscOnSpan = function freezeDscOnSpan(arg0, arg1) {
2026-07-23 10:11:24 +00:00
const result = require(799) /* addNonEnumerableProperty */.addNonEnumerableProperty(arg0, _frozenDsc, arg1);
2026-07-20 16:05:17 +00:00
};
arg5.getDynamicSamplingContextFromClient = getDynamicSamplingContextFromClient;
arg5.getDynamicSamplingContextFromScope = function getDynamicSamplingContextFromScope(arg0, getPropagationContext) {
const propagationContext = getPropagationContext.getPropagationContext();
let dsc = propagationContext.dsc;
if (!dsc) {
dsc = getDynamicSamplingContextFromClient(propagationContext.traceId, arg0);
}
return dsc;
};
arg5.getDynamicSamplingContextFromSpan = getDynamicSamplingContextFromSpan;
arg5.spanToBaggageHeader = function spanToBaggageHeader(arg0) {
const tmp = getDynamicSamplingContextFromSpan(arg0);
2026-07-23 10:11:24 +00:00
return require(812) /* parseBaggageHeader */.dynamicSamplingContextToSentryBaggageHeader(tmp);
2026-07-20 16:05:17 +00:00
};