Package org.apache.hadoop.hbase.trace
Class TraceUtil
java.lang.Object
org.apache.hadoop.hbase.trace.TraceUtil
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
TraceUtil.ThrowingCallable<R,
T extends Throwable> ACallable
that may also throw.static interface
TraceUtil.ThrowingRunnable<T extends Throwable>
ARunnable
that may also throw. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.opentelemetry.api.trace.Span
createClientSpan
(String name) Create a span withSpanKind.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 aSpanKind.INTERNAL
span.private static io.opentelemetry.api.trace.Span
createSpan
(String name, io.opentelemetry.api.trace.SpanKind kind) Create a span with the givenkind
.private static void
endSpan
(CompletableFuture<?> future, io.opentelemetry.api.trace.Span span) Finish thespan
when the givenfuture
is completed.static io.opentelemetry.api.trace.Tracer
static void
static <R,
T extends Throwable>
Rtrace
(TraceUtil.ThrowingCallable<R, T> callable, String spanName) static <R,
T extends Throwable>
Rtrace
(TraceUtil.ThrowingCallable<R, T> callable, Supplier<io.opentelemetry.api.trace.Span> spanSupplier) static <T extends Throwable>
voidtrace
(TraceUtil.ThrowingRunnable<T> runnable, String spanName) Trace the execution ofrunnable
.static <T extends Throwable>
voidtrace
(TraceUtil.ThrowingRunnable<T> runnable, Supplier<io.opentelemetry.api.trace.Span> spanSupplier) Trace the execution ofrunnable
.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 createSpan
when all the givenfutures
are completed.static Runnable
tracedRunnable
(Runnable runnable, String spanName) Wrap the providedrunnable
in aRunnable
that is traced.static Runnable
tracedRunnable
(Runnable runnable, Supplier<io.opentelemetry.api.trace.Span> spanSupplier) Wrap the providedrunnable
in aRunnable
that is traced.
-
Constructor Details
-
TraceUtil
private TraceUtil()
-
-
Method Details
-
getGlobalTracer
-
createSpan
Create aSpanKind.INTERNAL
span. -
createSpan
private static io.opentelemetry.api.trace.Span createSpan(String name, io.opentelemetry.api.trace.SpanKind kind) Create a span with the givenkind
. Notice that, OpenTelemetry only expects oneSpanKind.CLIENT
span and oneSpanKind.SERVER
span for a traced request, so use this with caution when you want to create spans with kind other thanSpanKind.INTERNAL
. -
createRemoteSpan
public 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. We will set the kind of the returned span toSpanKind.SERVER
, as this should be the top most span at server side. -
createClientSpan
Create a span withSpanKind.CLIENT
. -
tracedFuture
public static <T> CompletableFuture<T> tracedFuture(Supplier<CompletableFuture<T>> action, Supplier<io.opentelemetry.api.trace.Span> spanSupplier) Trace an asynchronous operation for a table. -
tracedFuture
public static <T> CompletableFuture<T> tracedFuture(Supplier<CompletableFuture<T>> action, String spanName) Trace an asynchronous operation. -
tracedFutures
public 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 createSpan
when all the givenfutures
are completed. -
setError
-
endSpan
Finish thespan
when the givenfuture
is completed. -
tracedRunnable
Wrap the providedrunnable
in aRunnable
that is traced. -
tracedRunnable
public static Runnable tracedRunnable(Runnable runnable, Supplier<io.opentelemetry.api.trace.Span> spanSupplier) Wrap the providedrunnable
in aRunnable
that is traced. -
trace
public static <T extends Throwable> void trace(TraceUtil.ThrowingRunnable<T> runnable, String spanName) throws T Trace the execution ofrunnable
.- Throws:
T extends Throwable
-
trace
public static <T extends Throwable> void trace(TraceUtil.ThrowingRunnable<T> runnable, Supplier<io.opentelemetry.api.trace.Span> spanSupplier) throws T Trace the execution ofrunnable
.- Throws:
T extends Throwable
-
trace
public static <R,T extends Throwable> R trace(TraceUtil.ThrowingCallable<R, T> callable, String spanName) throws T- Throws:
T extends Throwable
-
trace
public static <R,T extends Throwable> R trace(TraceUtil.ThrowingCallable<R, T> callable, Supplier<io.opentelemetry.api.trace.Span> spanSupplier) throws T- Throws:
T extends Throwable
-