public long getEpochMicros() { return getEpochMicros(System.nanoTime()); }
@Override public Span createSpan() { return createSpan(traceContext.getClock().getEpochMicros()); }
public void end() { end(traceContext.getClock().getEpochMicros()); }
public T captureException(@Nullable Throwable t) { if (t != null) { captureException(getTraceContext().getClock().getEpochMicros(), t); } return (T) this; }
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 <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; }
@Test void testEpochMicros() { epochTickClock.init(0, 0); final int nanoTime = 1000; assertThat(epochTickClock.getEpochMicros(nanoTime)).isEqualTo(TimeUnit.NANOSECONDS.toMicros(nanoTime)); } }