use of brave.internal.Nullable in project brave by openzipkin.
the class ThreadLocalSpan method remove.
/**
* Returns the span set in scope via {@link #next()} or null if there was none.
*
* <p>When assertions are on, this will throw an assertion error if the span returned was not the
* one currently in context. This could happen if someone called {@link Tracer#withSpanInScope(Span)}
* or {@link CurrentTraceContext#newScope(TraceContext)} outside a try/finally block.
*/
@Nullable
public Span remove() {
Tracer tracer = tracer();
Span currentSpan = tracer != null ? tracer.currentSpan() : null;
SpanAndScope scope = currentSpanInScope.get().pollFirst();
if (scope == null)
return currentSpan;
scope.scope().close();
assert scope.span().equals(currentSpan) : "Misalignment: scoped span " + scope.span() + " != current span " + currentSpan;
return currentSpan;
}
use of brave.internal.Nullable in project brave by openzipkin.
the class ThreadLocalSpan method next.
/**
* Returns the {@link Tracer#nextSpan(TraceContextOrSamplingFlags)} or null if {@link #CURRENT_TRACER}
* and tracing isn't available.
*/
@Nullable
public Span next(TraceContextOrSamplingFlags extracted) {
Tracer tracer = tracer();
if (tracer == null)
return null;
Span next = tracer.nextSpan(extracted);
SpanAndScope spanAndScope = SpanAndScope.create(next, tracer.withSpanInScope(next));
currentSpanInScope.get().addFirst(spanAndScope);
return next;
}
use of brave.internal.Nullable in project brave by openzipkin.
the class ThreadLocalSpan method next.
/**
* Returns the {@link Tracer#nextSpan()} or null if {@link #CURRENT_TRACER} and tracing isn't
* available.
*/
@Nullable
public Span next() {
Tracer tracer = tracer();
if (tracer == null)
return null;
Span next = tracer.nextSpan();
SpanAndScope spanAndScope = SpanAndScope.create(next, tracer.withSpanInScope(next));
currentSpanInScope.get().addFirst(spanAndScope);
return next;
}
use of brave.internal.Nullable in project brave by openzipkin.
the class AWSPropagation method currentTraceId.
/**
* Returns the current {@link #traceId(TraceContext)} or null if not available
*/
@Nullable
public static String currentTraceId() {
Tracing tracing = Tracing.current();
if (tracing == null)
return null;
TraceContext context = tracing.currentTraceContext().get();
if (context == null)
return null;
return traceId(context);
}
Aggregations