Tracer { @Nullable public Span currentSpan() { TraceContext context = currentTraceContext.get(); if (context == null) return null; return new LazySpan(this, 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 currentSpan_defaultsToNull() { assertThat(tracer.currentSpan()).isNull(); }
@Test public void currentSpan_decoratesExternalContext() { try (Scope ws = currentTraceContext.newScope(context)) { assertThat(tracer.currentSpan().context()) .isNotSameAs(context) .extracting(TraceContext::localRootId) .isEqualTo(context.spanId()); } }
@Test public void currentSpan_retainsSharedFlag() { TraceContext context = TraceContext.newBuilder().traceId(1L).spanId(2L).shared(true).sampled(true).build(); try (Scope ws = currentTraceContext.newScope(context)) { assertThat(tracer.currentSpan().context().shared()).isTrue(); } }
@Test public void currentSpan_doesntSetSharedFlag() { try (Scope ws = currentTraceContext.newScope(context)) { assertThat(tracer.currentSpan().context().shared()).isFalse(); } }