Modifier and Type | Class and Description |
---|---|
static interface |
TraceUtil.ThrowingCallable<R,T extends Throwable>
A
Callable that may also throw. |
static interface |
TraceUtil.ThrowingRunnable<T extends Throwable>
A
Runnable that may also throw. |
Modifier | Constructor and Description |
---|---|
private |
TraceUtil() |
Modifier and Type | Method and Description |
---|---|
static io.opentelemetry.api.trace.Span |
createClientSpan(String name)
Create a span with
SpanKind.CLIENT . |
static io.opentelemetry.api.trace.Span |
createRemoteSpan(String name,
io.opentelemetry.context.Context ctx)
Create a span which parent is from remote, i.e, passed through rpc.
|
static io.opentelemetry.api.trace.Span |
createSpan(String name)
Create a
SpanKind.INTERNAL span. |
private static io.opentelemetry.api.trace.Span |
createSpan(String name,
io.opentelemetry.api.trace.SpanKind kind)
Create a span with the given
kind . |
private static void |
endSpan(CompletableFuture<?> future,
io.opentelemetry.api.trace.Span span)
Finish the
span when the given future is completed. |
static io.opentelemetry.api.trace.Tracer |
getGlobalTracer() |
static void |
setError(io.opentelemetry.api.trace.Span span,
Throwable error) |
static <R,T extends Throwable> |
trace(TraceUtil.ThrowingCallable<R,T> callable,
String spanName) |
static <R,T extends Throwable> |
trace(TraceUtil.ThrowingCallable<R,T> callable,
Supplier<io.opentelemetry.api.trace.Span> spanSupplier) |
static <T extends Throwable> |
trace(TraceUtil.ThrowingRunnable<T> runnable,
String spanName)
Trace the execution of
runnable . |
static <T extends Throwable> |
trace(TraceUtil.ThrowingRunnable<T> runnable,
Supplier<io.opentelemetry.api.trace.Span> spanSupplier)
Trace the execution of
runnable . |
static <T> CompletableFuture<T> |
tracedFuture(Supplier<CompletableFuture<T>> action,
String spanName)
Trace an asynchronous operation.
|
static <T> CompletableFuture<T> |
tracedFuture(Supplier<CompletableFuture<T>> action,
Supplier<io.opentelemetry.api.trace.Span> spanSupplier)
Trace an asynchronous operation for a table.
|
static <T> List<CompletableFuture<T>> |
tracedFutures(Supplier<List<CompletableFuture<T>>> action,
Supplier<io.opentelemetry.api.trace.Span> spanSupplier)
Trace an asynchronous operation, and finish the create
Span when all the given
futures are completed. |
static Runnable |
tracedRunnable(Runnable runnable,
String spanName)
Wrap the provided
runnable in a Runnable that is traced. |
static Runnable |
tracedRunnable(Runnable runnable,
Supplier<io.opentelemetry.api.trace.Span> spanSupplier)
Wrap the provided
runnable in a Runnable that is traced. |
private TraceUtil()
public static io.opentelemetry.api.trace.Tracer getGlobalTracer()
public static io.opentelemetry.api.trace.Span createSpan(String name)
SpanKind.INTERNAL
span.private static io.opentelemetry.api.trace.Span createSpan(String name, io.opentelemetry.api.trace.SpanKind kind)
kind
. Notice that, OpenTelemetry only expects one
SpanKind.CLIENT
span and one SpanKind.SERVER
span for a traced request, so use
this with caution when you want to create spans with kind other than SpanKind.INTERNAL
.public static io.opentelemetry.api.trace.Span createRemoteSpan(String name, io.opentelemetry.context.Context ctx)
SpanKind.SERVER
, as this should be the top
most span at server side.public static io.opentelemetry.api.trace.Span createClientSpan(String name)
SpanKind.CLIENT
.public static <T> CompletableFuture<T> tracedFuture(Supplier<CompletableFuture<T>> action, Supplier<io.opentelemetry.api.trace.Span> spanSupplier)
public static <T> CompletableFuture<T> tracedFuture(Supplier<CompletableFuture<T>> action, String spanName)
public static <T> List<CompletableFuture<T>> tracedFutures(Supplier<List<CompletableFuture<T>>> action, Supplier<io.opentelemetry.api.trace.Span> spanSupplier)
Span
when all the given
futures
are completed.private static void endSpan(CompletableFuture<?> future, io.opentelemetry.api.trace.Span span)
span
when the given future
is completed.public static Runnable tracedRunnable(Runnable runnable, String spanName)
runnable
in a Runnable
that is traced.public static Runnable tracedRunnable(Runnable runnable, Supplier<io.opentelemetry.api.trace.Span> spanSupplier)
runnable
in a Runnable
that is traced.public static <T extends Throwable> void trace(TraceUtil.ThrowingRunnable<T> runnable, String spanName) throws T extends Throwable
runnable
.T extends Throwable
public static <T extends Throwable> void trace(TraceUtil.ThrowingRunnable<T> runnable, Supplier<io.opentelemetry.api.trace.Span> spanSupplier) throws T extends Throwable
runnable
.T extends Throwable
public static <R,T extends Throwable> R trace(TraceUtil.ThrowingCallable<R,T> callable, String spanName) throws T extends Throwable
T extends Throwable
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.