Skip to content

Commit 89b7166

Browse files
authored
Propagate Trace Context Level 2 random flag (#1731)
* Propagate Trace Context Level 2 random flag in `TraceContextPropagator` * Propagate Trace Context Level 2 random flag in SDK `SpanBuilder`
1 parent 8a12f92 commit 89b7166

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Trace/SpanBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,15 @@ public function startSpan(): API\SpanInterface
155155
$samplingDecision = $samplingResult->getDecision();
156156
$samplingResultTraceState = $samplingResult->getTraceState();
157157

158+
$flags = $parentSpanContext->getTraceFlags() & 0x2;
159+
if ($samplingDecision === SamplingResult::RECORD_AND_SAMPLE) {
160+
$flags |= API\TraceFlags::SAMPLED;
161+
}
162+
158163
$spanContext = API\SpanContext::create(
159164
$traceId,
160165
$spanId,
161-
SamplingResult::RECORD_AND_SAMPLE === $samplingDecision ? API\TraceFlags::SAMPLED : API\TraceFlags::DEFAULT,
166+
$flags,
162167
$samplingResultTraceState,
163168
);
164169

0 commit comments

Comments
 (0)