Search in sources :

Example 1 with PendingSpan

use of brave.internal.recorder.PendingSpan in project brave by openzipkin.

the class Tracer method newScopedSpan.

ScopedSpan newScopedSpan(@Nullable TraceContext parent, TraceContext context, String name) {
    Scope scope = currentTraceContext.newScope(context);
    if (isNoop(context))
        return new NoopScopedSpan(context, scope);
    PendingSpan pendingSpan = pendingSpans.getOrCreate(parent, context, true);
    Clock clock = pendingSpan.clock();
    MutableSpan state = pendingSpan.state();
    state.name(name);
    return new RealScopedSpan(context, scope, state, clock, pendingSpans);
}
Also used : MutableSpan(brave.handler.MutableSpan) Scope(brave.propagation.CurrentTraceContext.Scope) PendingSpan(brave.internal.recorder.PendingSpan)

Example 2 with PendingSpan

use of brave.internal.recorder.PendingSpan in project brave by openzipkin.

the class Tracer method _toSpan.

Span _toSpan(@Nullable TraceContext parent, TraceContext context) {
    if (isNoop(context))
        return new NoopSpan(context);
    // allocate a mutable span in case multiple threads call this method.. they'll use the same data
    PendingSpan pendingSpan = pendingSpans.getOrCreate(parent, context, false);
    TraceContext pendingContext = pendingSpan.context();
    // the same as pendingSpan.context()
    if (pendingContext != null)
        context = pendingContext;
    return new RealSpan(context, pendingSpans, pendingSpan.state(), pendingSpan.clock());
}
Also used : PendingSpan(brave.internal.recorder.PendingSpan) CurrentTraceContext(brave.propagation.CurrentTraceContext) TraceContext(brave.propagation.TraceContext)

Aggregations

PendingSpan (brave.internal.recorder.PendingSpan)2 MutableSpan (brave.handler.MutableSpan)1 CurrentTraceContext (brave.propagation.CurrentTraceContext)1 Scope (brave.propagation.CurrentTraceContext.Scope)1 TraceContext (brave.propagation.TraceContext)1