/** * Initializes the current thread's trace, erasing any previously accrued open spans. The new trace is {@link * Trace#isObservable observable} iff the given flag is true, or, iff {@code isObservable} is absent, if the {@link * #setSampler configured sampler} returns true. */ public static void initTrace(Optional<Boolean> isObservable, String traceId) { setTrace(createTrace(isObservable, traceId)); }
static ZipkinCompatSpan fromSpan(Span span, ZipkinCompatEndpoint endpoint) { return ImmutableZipkinCompatSpan.builder() .traceId(span.getTraceId()) .id(span.getSpanId()) .name(span.getOperation()) .parentId(span.getParentSpanId()) .timestamp(span.getStartTimeMicroSeconds()) .duration(nanoToMicro(span.getDurationNanoSeconds())) // Zipkin-durations are micro-seconds, round .addAllAnnotations(spanTypeToZipkinAnnotations(span, endpoint)) .addAllBinaryAnnotations(spanMetadataToZipkinBinaryAnnotations(span, endpoint)) .build(); }
/** * Runs the given callable with the current trace at * the time of construction of this {@link DeferredTracer}. */ public <T, E extends Throwable> T withTrace(ThrowingCallable<T, E> inner) throws E { Trace originalTrace = Tracer.copyTrace(); Tracer.setTrace(trace); try { return inner.call(); } finally { Tracer.setTrace(originalTrace); } } }
/** * Opens a new {@link SpanType#LOCAL LOCAL} span for this thread's call trace, labeled with the provided operation. */ public static CloseableTracer startSpan(String operation) { Tracer.startSpan(operation); return INSTANCE; }
@Override protected <T> Callable<T> wrapTask(Callable<T> callable) { return wrapWithNewTrace(callable); } };
@Override protected <T> Callable<T> wrapTask(Callable<T> callable) { return wrap(callable); } };
/** * Opens a new {@link SpanType#LOCAL LOCAL} span for this thread's call trace, labeled with the provided operation. */ public static OpenSpan startSpan(String operation) { return startSpanInternal(operation, SpanType.LOCAL); }
@Override public void close() { Tracer.fastCompleteSpan(); } }
/** * Wraps the given {@link Callable} such that it uses the thread-local {@link Trace tracing state} at the time of * it's construction during its {@link Callable#call() execution}. */ public static <V> Callable<V> wrap(Callable<V> delegate) { return new TracingAwareCallable<>(delegate); }
static ZipkinCompatSpan fromSpan(Span span, ZipkinCompatEndpoint endpoint) { return ImmutableZipkinCompatSpan.builder() .traceId(span.getTraceId()) .id(span.getSpanId()) .name(span.getOperation()) .parentId(span.getParentSpanId()) .timestamp(span.getStartTimeMicroSeconds()) .duration(nanoToMicro(span.getDurationNanoSeconds())) // Zipkin-durations are micro-seconds, round .addAllAnnotations(spanTypeToZipkinAnnotations(span, endpoint)) .addAllBinaryAnnotations(spanMetadataToZipkinBinaryAnnotations(span, endpoint)) .build(); }
/** * Runs the given callable with the current trace at * the time of construction of this {@link DeferredTracer}. */ public <T, E extends Throwable> T withTrace(ThrowingCallable<T, E> inner) throws E { Trace originalTrace = Tracer.copyTrace(); Tracer.setTrace(trace); try { return inner.call(); } finally { Tracer.setTrace(originalTrace); } } }
/** * Initializes the current thread's trace, erasing any previously accrued open spans. The new trace is {@link * Trace#isObservable observable} iff the given flag is true, or, iff {@code isObservable} is absent, if the {@link * #setSampler configured sampler} returns true. */ public static void initTrace(Optional<Boolean> isObservable, String traceId) { setTrace(createTrace(isObservable, traceId)); }
@Override protected <T> Callable<T> wrapTask(Callable<T> callable) { return wrapWithNewTrace(callable); } };
@Override protected <T> Callable<T> wrapTask(Callable<T> callable) { return wrap(callable); } };
/** * Opens a new {@link SpanType#LOCAL LOCAL} span for this thread's call trace, labeled with the provided operation. */ public static OpenSpan startSpan(String operation) { return startSpanInternal(operation, SpanType.LOCAL); }
@Override protected <T> Callable<T> wrapTask(Callable<T> callable) { return wrapWithNewTrace(callable); } };