/** Resolves hash code collisions */ @Override public boolean equals(Object other) { RealKey that = (RealKey) other; TraceContext thatContext = that.get(); if (thatContext == null) return false; return (traceIdHigh == thatContext.traceIdHigh()) && (traceId == thatContext.traceId()) && (spanId == thatContext.spanId()) && shared == thatContext.shared(); } }
void set(TraceContext context) { set(context.traceIdHigh(), context.traceId(), context.spanId(), context.shared()); }
/** 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; }
public PendingSpan getOrCreate(TraceContext context, boolean start) { if (context == null) throw new NullPointerException("context == null"); reportOrphanedSpans(); PendingSpan result = delegate.get(context); if (result != null) return result; MutableSpan data = new MutableSpan(); if (context.shared()) data.setShared(); // save overhead calculating time if the parent is in-progress (usually is) TickClock clock = getClockFromParent(context); if (clock == null) { clock = new TickClock(this.clock.currentTimeMicroseconds(), System.nanoTime()); if (start) data.startTimestamp(clock.baseEpochMicros); } else if (start) { data.startTimestamp(clock.currentTimeMicroseconds()); } PendingSpan newSpan = new PendingSpan(data, clock); PendingSpan previousSpan = delegate.putIfAbsent(new RealKey(context, this), newSpan); if (previousSpan != null) return previousSpan; // lost race return newSpan; }
/** Resolves hash code collisions */ @Override public boolean equals(Object other) { RealKey that = (RealKey) other; TraceContext thatContext = that.get(); if (thatContext == null) return false; return (traceIdHigh == thatContext.traceIdHigh()) && (traceId == thatContext.traceId()) && (spanId == thatContext.spanId()) && shared == thatContext.shared(); } }
void set(TraceContext context) { set(context.traceIdHigh(), context.traceId(), context.spanId(), context.shared()); }
/** 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; }
public PendingSpan getOrCreate(TraceContext context, boolean start) { if (context == null) throw new NullPointerException("context == null"); reportOrphanedSpans(); PendingSpan result = delegate.get(context); if (result != null) return result; MutableSpan data = new MutableSpan(); if (context.shared()) data.setShared(); // save overhead calculating time if the parent is in-progress (usually is) TickClock clock = getClockFromParent(context); if (clock == null) { clock = new TickClock(this.clock.currentTimeMicroseconds(), System.nanoTime()); if (start) data.startTimestamp(clock.baseEpochMicros); } else if (start) { data.startTimestamp(clock.currentTimeMicroseconds()); } PendingSpan newSpan = new PendingSpan(data, clock); PendingSpan previousSpan = delegate.putIfAbsent(new RealKey(context, this), newSpan); if (previousSpan != null) return previousSpan; // lost race return newSpan; }