/** Reports spans orphaned by garbage collection. */ void reportOrphanedSpans() { RealKey contextKey; // This is called on critical path of unrelated traced operations. If we have orphaned spans, be // careful to not penalize the performance of the caller. It is better to cache time when // flushing a span than hurt performance of unrelated operations by calling // currentTimeMicroseconds N times long flushTime = 0L; boolean noop = zipkinHandler == FinishedSpanHandler.NOOP || this.noop.get(); while ((contextKey = (RealKey) poll()) != null) { PendingSpan value = delegate.remove(contextKey); if (noop || value == null || !contextKey.sampled) continue; if (flushTime == 0L) flushTime = clock.currentTimeMicroseconds(); TraceContext context = InternalPropagation.instance.newTraceContext( InternalPropagation.FLAG_SAMPLED_SET | InternalPropagation.FLAG_SAMPLED, contextKey.traceIdHigh, contextKey.traceId, contextKey.localRootId, 0L, contextKey.spanId, Collections.emptyList() ); value.state.annotate(flushTime, "brave.flush"); try { zipkinHandler.handle(context, value.state); } catch (RuntimeException e) { Platform.get().log("error reporting {0}", context, e); } } }
/** Trace contexts are equal only on trace ID and span ID. try to get the parent's clock */ @Nullable TickClock getClockFromParent(TraceContext context) { long parentId = context.parentIdAsLong(); // NOTE: we still look for lookup key even on root span, as a client span can be root, and a // server can share the same ID. Essentially, a shared span is similar to a child. PendingSpan parent = null; if (context.shared() || parentId != 0L) { long spanId = parentId != 0L ? parentId : context.spanId(); parent = delegate.get(InternalPropagation.instance.newTraceContext( 0, context.traceIdHigh(), context.traceId(), 0, 0, spanId, Collections.emptyList() )); } return parent != null ? parent.clock : null; }
return propagationFactory.decorate(InternalPropagation.instance.newTraceContext( flags, traceIdHigh,
context = InternalPropagation.instance.newTraceContext( flags | FLAG_LOCAL_ROOT, context.traceIdHigh(),
/** Reports spans orphaned by garbage collection. */ void reportOrphanedSpans() { RealKey contextKey; // This is called on critical path of unrelated traced operations. If we have orphaned spans, be // careful to not penalize the performance of the caller. It is better to cache time when // flushing a span than hurt performance of unrelated operations by calling // currentTimeMicroseconds N times long flushTime = 0L; boolean noop = zipkinHandler == FinishedSpanHandler.NOOP || this.noop.get(); while ((contextKey = (RealKey) poll()) != null) { PendingSpan value = delegate.remove(contextKey); if (noop || value == null || !contextKey.sampled) continue; if (flushTime == 0L) flushTime = clock.currentTimeMicroseconds(); TraceContext context = InternalPropagation.instance.newTraceContext( InternalPropagation.FLAG_SAMPLED_SET | InternalPropagation.FLAG_SAMPLED, contextKey.traceIdHigh, contextKey.traceId, contextKey.localRootId, 0L, contextKey.spanId, Collections.emptyList() ); value.state.annotate(flushTime, "brave.flush"); try { zipkinHandler.handle(context, value.state); } catch (RuntimeException e) { Platform.get().log("error reporting {0}", context, e); } } }
/** Trace contexts are equal only on trace ID and span ID. try to get the parent's clock */ @Nullable TickClock getClockFromParent(TraceContext context) { long parentId = context.parentIdAsLong(); // NOTE: we still look for lookup key even on root span, as a client span can be root, and a // server can share the same ID. Essentially, a shared span is similar to a child. PendingSpan parent = null; if (context.shared() || parentId != 0L) { long spanId = parentId != 0L ? parentId : context.spanId(); parent = delegate.get(InternalPropagation.instance.newTraceContext( 0, context.traceIdHigh(), context.traceId(), 0, 0, spanId, Collections.emptyList() )); } return parent != null ? parent.clock : null; }
return propagationFactory.decorate(InternalPropagation.instance.newTraceContext( flags, traceIdHigh,
context = InternalPropagation.instance.newTraceContext( flags | FLAG_LOCAL_ROOT, context.traceIdHigh(),