Skip to content

Commit 0b12615

Browse files
author
Luca Forstner
committed
Inject sample rand
1 parent 7fbba52 commit 0b12615

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/core/src/tracing/dynamicSamplingContext.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { addNonEnumerableProperty, dropUndefinedKeys } from '../utils-hoist/object';
1212
import { hasTracingEnabled } from '../utils/hasTracingEnabled';
1313
import { getRootSpan, spanIsSampled, spanToJSON } from '../utils/spanUtils';
14+
import { getCapturedScopesOnSpan } from './utils';
1415

1516
/**
1617
* If you change this value, also update the terser plugin config to
@@ -116,7 +117,7 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<
116117
// So we end up with an active span that is not sampled (neither positively nor negatively)
117118
if (hasTracingEnabled()) {
118119
dsc.sampled = String(spanIsSampled(rootSpan));
119-
// TODO(lforst): Grab scope off of root span and put sample_rand on dsc
120+
dsc.sample_rand = getCapturedScopesOnSpan(rootSpan).scope?.getPropagationContext().sampleRand.toString();
120121
}
121122

122123
client.emit('createDsc', dsc, rootSpan);

packages/opentelemetry/src/propagator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export function getInjectionData(context: Context): {
171171
dynamicSamplingContext,
172172
traceId: spanContext.traceId,
173173
spanId: undefined,
174-
sampled: getSamplingDecision(spanContext),
174+
sampled: getSamplingDecision(spanContext), // TODO: Do we need to change something here?
175175
};
176176
}
177177

@@ -184,7 +184,7 @@ export function getInjectionData(context: Context): {
184184
dynamicSamplingContext,
185185
traceId: spanContext.traceId,
186186
spanId: spanContext.spanId,
187-
sampled: getSamplingDecision(spanContext),
187+
sampled: getSamplingDecision(spanContext), // TODO: Do we need to change something here?
188188
};
189189
}
190190

0 commit comments

Comments
 (0)