ThreadLocalSpan { @Nullable public Span next(TraceContextOrSamplingFlags extracted) { Tracer tracer = tracer(); if (tracer == null) return null; Span next = tracer.nextSpan(extracted); SpanAndScope spanAndScope = new SpanAndScope(next, tracer.withSpanInScope(next)); getCurrentSpanInScopeStack().addFirst(spanAndScope); return next; } ThreadLocalSpan(Tracer tracer); static ThreadLocalSpan create(Tracer tracer); @Nullable Span next(TraceContextOrSamplingFlags extracted); @Nullable Span next(); @Nullable Span remove(); static final ThreadLocalSpan CURRENT_TRACER; }
@Test public void next() { assertThat(threadLocalSpan.next()) .isEqualTo(threadLocalSpan.remove()); }