public long getEpochMicros() { return getEpochMicros(System.nanoTime()); }
/** * Initializes and calibrates the clock based on wall clock time * * @return the epoch microsecond timestamp at initialization time */ public long init() { return init(System.currentTimeMillis() * 1000, System.nanoTime()); }
@Test void testEpochMicros() { epochTickClock.init(0, 0); final int nanoTime = 1000; assertThat(epochTickClock.getEpochMicros(nanoTime)).isEqualTo(TimeUnit.NANOSECONDS.toMicros(nanoTime)); } }
@Override public void resetState() { traceId.resetState(); id.resetState(); parentId.resetState(); outgoingHeader.setLength(0); flags = 0; clock.resetState(); }
@BeforeEach void setUp() { epochTickClock = new EpochTickClock(); }
@Override public Span createSpan() { return createSpan(traceContext.getClock().getEpochMicros()); }
public void copyFrom(TraceContext other) { traceId.copyFrom(other.traceId); id.copyFrom(other.id); parentId.copyFrom(other.parentId); transactionId.copyFrom(other.transactionId); outgoingHeader.append(other.outgoingHeader); flags = other.flags; clock.init(other.clock); onMutation(); }
public void end() { end(traceContext.getClock().getEpochMicros()); }
public void asChildOf(TraceContext parent) { traceId.copyFrom(parent.traceId); parentId.copyFrom(parent.id); transactionId.copyFrom(parent.transactionId); flags = parent.flags; id.setToRandomValue(); clock.init(parent.clock); onMutation(); }
public T captureException(@Nullable Throwable t) { if (t != null) { captureException(getTraceContext().getClock().getEpochMicros(), t); } return (T) this; }
clock.init(); return true; } catch (IllegalArgumentException e) {
public <T> Span start(TraceContext.ChildContextCreator<T> childContextCreator, T parentContext, long epochMicros, boolean dropped) { onStart(); childContextCreator.asChildOf(traceContext, parentContext); if (dropped) { traceContext.setRecorded(false); } if (epochMicros >= 0) { timestamp = epochMicros; } else { timestamp = getTraceContext().getClock().getEpochMicros(); } if (logger.isDebugEnabled()) { logger.debug("startSpan {} {", this); if (logger.isTraceEnabled()) { logger.trace("starting span at", new RuntimeException("this exception is just used to record where the span has been started from")); } } return this; }
public void asRootSpan(Sampler sampler) { traceId.setToRandomValue(); id.setToRandomValue(); transactionId.copyFrom(id); if (sampler.isSampled(traceId)) { this.flags = FLAG_RECORDED; } clock.init(); onMutation(); }
public <T> Transaction start(TraceContext.ChildContextCreator<T> childContextCreator, @Nullable T parent, long epochMicros, Sampler sampler) { onStart(); if (parent == null || !childContextCreator.asChildOf(traceContext, parent)) { traceContext.asRootSpan(sampler); } if (epochMicros >= 0) { this.timestamp = epochMicros; } else { this.timestamp = traceContext.getClock().getEpochMicros(); } return this; }