File tree Expand file tree Collapse file tree
sdk/trace/src/main/java/io/opentelemetry/sdk/trace Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3636
3737/** {@link SdkSpanBuilder} is SDK implementation of {@link SpanBuilder}. */
3838class SdkSpanBuilder implements SpanBuilder {
39-
40- private static final Context ROOT_CONTEXT_WITH_RANDOM_TRACE_ID_BIT =
41- preparePrimordialContext (
42- TraceFlags .builder ().setRandomTraceId (true ).build (), TraceState .getDefault ());
43-
4439 private final String spanName ;
4540 private final InstrumentationScopeInfo instrumentationScopeInfo ;
4641 private final TracerSharedState tracerSharedState ;
@@ -198,7 +193,11 @@ public Span startSpan() {
198193 if (idGenerator .generatesRandomTraceIds ()) {
199194 isTraceIdRandom = true ;
200195 // Replace parentContext for sampling with one with RANDOM_TRACE_ID bit set
201- parentContextForSampler = ROOT_CONTEXT_WITH_RANDOM_TRACE_ID_BIT ;
196+ SpanContext primordialSpan = SpanContext .create (
197+ TraceId .getInvalid (), SpanId .getInvalid (),
198+ TraceFlags .builder ().setRandomTraceId (true ).build (),
199+ TraceState .getDefault ());
200+ parentContextForSampler = parentContext .with (Span .wrap (primordialSpan ));
202201 } else {
203202 isTraceIdRandom = false ;
204203 }
You can’t perform that action at this time.
0 commit comments