@@ -10,6 +10,10 @@ const {
1010 SAMPLED_PROBE_OVERFLOW_INDEX ,
1111} = require ( './probe_sampler_constants' )
1212
13+ const ddTraceGlobal = /** @type {Record<symbol, SharedArrayBuffer | object | undefined> } */ (
14+ /** @type {Record<symbol, unknown> } */ ( globalThis ) [ Symbol . for ( DD_TRACE_SYMBOL ) ]
15+ )
16+
1317module . exports = {
1418 installProbeSampler,
1519 uninstallProbeSampler,
@@ -21,7 +25,6 @@ module.exports = {
2125 * @returns {SharedArrayBuffer } The shared sampler buffer to pass to the debugger worker.
2226 */
2327function installProbeSampler ( ) {
24- const ddTrace = getDatadogGlobal ( )
2528 const buffer = createProbeSamplerBuffer ( )
2629
2730 const lastCaptureNsByProbeId = new Map ( )
@@ -33,7 +36,7 @@ function installProbeSampler () {
3336 let globalSnapshotSamplingRateWindowStart = 0n
3437 let snapshotsSampledWithinTheLastSecond = 0
3538
36- ddTrace [ Symbol . for ( PROBE_SAMPLER_SYMBOL ) ] = {
39+ ddTraceGlobal [ Symbol . for ( PROBE_SAMPLER_SYMBOL ) ] = {
3740 /**
3841 * Decide if a probe should be sampled and store sampled probe indexes for the debugger worker.
3942 *
@@ -94,19 +97,7 @@ function installProbeSampler () {
9497 * Remove the runtime sampler from the debuggee context.
9598 */
9699function uninstallProbeSampler ( ) {
97- const ddTrace = getDatadogGlobal ( )
98- delete ddTrace [ Symbol . for ( PROBE_SAMPLER_SYMBOL ) ]
99- }
100-
101- /**
102- * Get the Datadog global object.
103- *
104- * @returns {Record<symbol, SharedArrayBuffer | object | undefined> }
105- */
106- function getDatadogGlobal ( ) {
107- return /** @type {Record<symbol, SharedArrayBuffer | object | undefined> } */ (
108- /** @type {Record<symbol, unknown> } */ ( globalThis ) [ Symbol . for ( DD_TRACE_SYMBOL ) ]
109- )
100+ delete ddTraceGlobal [ Symbol . for ( PROBE_SAMPLER_SYMBOL ) ]
110101}
111102
112103/**
0 commit comments