/** * Explicitly creates a new trace. The result will be a root span (no parent span ID). * * <p>To implicitly create a new trace, or a span within an existing one, use {@link * #nextSpan()}. */ public Span newTrace() { return _toSpan(newRootContext()); }
/** * Same as {@link #startScopedSpan(String)}, except ignores the current trace context. * * <p>Use this when you are creating a scoped span in a method block where the parent was * created. You can also use this to force a new trace by passing null parent. */ // this api is needed to make tools such as executors which need to carry the invocation context public ScopedSpan startScopedSpanWithParent(String name, @Nullable TraceContext parent) { if (name == null) throw new NullPointerException("name == null"); if (parent == null) parent = currentTraceContext.get(); TraceContext context = parent != null ? nextContext(parent) : newRootContext(); Scope scope = currentTraceContext.newScope(context); if (isNoop(context)) return new NoopScopedSpan(context, scope); PendingSpan pendingSpan = pendingSpans.getOrCreate(context, true); Clock clock = pendingSpan.clock(); MutableSpan state = pendingSpan.state(); state.name(name); return new RealScopedSpan(context, scope, state, clock, pendingSpans, finishedSpanHandler); }
/** * Explicitly creates a new trace. The result will be a root span (no parent span ID). * * <p>To implicitly create a new trace, or a span within an existing one, use {@link * #nextSpan()}. */ public Span newTrace() { return _toSpan(newRootContext()); }
/** * Same as {@link #startScopedSpan(String)}, except ignores the current trace context. * * <p>Use this when you are creating a scoped span in a method block where the parent was * created. You can also use this to force a new trace by passing null parent. */ // this api is needed to make tools such as executors which need to carry the invocation context public ScopedSpan startScopedSpanWithParent(String name, @Nullable TraceContext parent) { if (name == null) throw new NullPointerException("name == null"); if (parent == null) parent = currentTraceContext.get(); TraceContext context = parent != null ? nextContext(parent) : newRootContext(); Scope scope = currentTraceContext.newScope(context); if (isNoop(context)) return new NoopScopedSpan(context, scope); PendingSpan pendingSpan = pendingSpans.getOrCreate(context, true); Clock clock = pendingSpan.clock(); MutableSpan state = pendingSpan.state(); state.name(name); return new RealScopedSpan(context, scope, state, clock, pendingSpans, finishedSpanHandler); }