Tracer { public Span toSpan(TraceContext context) { return toSpan(null, context); } Tracer(
    Clock clock,
    Propagation.Factory propagationFactory,
    SpanHandler spanHandler,
    PendingSpans pendingSpans,
    Sampler sampler,
    CurrentTraceContext currentTraceContext,
    boolean traceId128Bit,
    boolean supportsJoin,
    boolean alwaysSampleLocal,
    AtomicBoolean noop
  ); @Deprecated Tracer withSampler(Sampler sampler); Span newTrace(); final Span joinSpan(TraceContext context); Span newChild(TraceContext parent); Span nextSpan(TraceContextOrSamplingFlags extracted); Span toSpan(TraceContext context); SpanInScope withSpanInScope(@Nullable Span span); SpanCustomizer currentSpanCustomizer(); @Nullable Span currentSpan(); Span nextSpan(); ScopedSpan startScopedSpan(String name); ScopedSpan startScopedSpan(String name, SamplerFunction<T> samplerFunction, T arg); Span nextSpan(SamplerFunction<T> samplerFunction, T arg); Span nextSpanWithParent(SamplerFunction<T> samplerFunction, T arg,
    @Nullable TraceContext parent); ScopedSpan startScopedSpanWithParent(String name, @Nullable TraceContext parent); @Override String toString();  }
@Test public void toSpan() { TraceContext context = tracer.newTrace().context(); assertThat(tracer.toSpan(context)) .isInstanceOf(RealSpan.class) .extracting(Span::context) .isEqualTo(context); }
@Test public void toSpan_decoratesExternalContext() { assertThat(tracer.toSpan(context).context()) .isNotSameAs(context) .extracting(TraceContext::localRootId) .isEqualTo(context.spanId()); }
@Test public void toSpan_decorates() { propagationFactory = baggageFactory; TraceContext incoming = TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(true).build(); TraceContext toSpan = tracer.toSpan(incoming).context(); assertThat(toSpan).isNotSameAs(incoming); assertThat(toSpan.extra()).isNotEmpty(); }
@Test public void toSpan_decorates_unsampled() { propagationFactory = baggageFactory; TraceContext incoming = TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(false).build(); TraceContext toSpan = tracer.toSpan(incoming).context(); assertThat(toSpan).isNotSameAs(incoming); assertThat(toSpan.extra()).isNotEmpty(); }
@Test public void toSpan_idempotent() { TraceContext incoming = TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(true).build(); TraceContext toSpan = tracer.toSpan(incoming).context(); assertThat(toSpan).isNotSameAs(incoming); assertThat(tracer.toSpan(incoming).context()).isSameAs(toSpan); }
@Test public void toSpan_idempotent_unsampled() { TraceContext incoming = TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(false).build(); TraceContext toSpan = tracer.toSpan(incoming).context(); assertThat(toSpan).isNotSameAs(incoming); assertThat(tracer.toSpan(incoming).context()) .isNotSameAs(toSpan); }