Package io.opencensus.trace
Class CurrentSpanUtils
- java.lang.Object
-
- io.opencensus.trace.CurrentSpanUtils
-
final class CurrentSpanUtils extends java.lang.Object
Util methods/functionality to interact with theSpan
in theContext
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CurrentSpanUtils.CallableInSpan<V>
private static class
CurrentSpanUtils.RunnableInSpan
private static class
CurrentSpanUtils.ScopeInSpan
-
Constructor Summary
Constructors Modifier Constructor Description private
CurrentSpanUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static Span
getCurrentSpan()
Returns TheSpan
from the current context.private static void
setErrorStatus(Span span, java.lang.Throwable t)
(package private) static Scope
withSpan(Span span, boolean endSpan)
Enters the scope of code where the givenSpan
is in the current context, and returns an object that represents that scope.(package private) static java.lang.Runnable
withSpan(Span span, boolean endSpan, java.lang.Runnable runnable)
Wraps aRunnable
so that it executes with thespan
as the currentSpan
.(package private) static <C> java.util.concurrent.Callable<C>
withSpan(Span span, boolean endSpan, java.util.concurrent.Callable<C> callable)
Wraps aCallable
so that it executes with thespan
as the currentSpan
.
-
-
-
Method Detail
-
getCurrentSpan
@Nullable static Span getCurrentSpan()
Returns TheSpan
from the current context.- Returns:
- The
Span
from the current context.
-
withSpan
static Scope withSpan(Span span, boolean endSpan)
Enters the scope of code where the givenSpan
is in the current context, and returns an object that represents that scope. The scope is exited when the returned object is closed.Supports try-with-resource idiom.
- Parameters:
span
- TheSpan
to be set to the current context.endSpan
- iftrue
the returnedScope
will close theSpan
.- Returns:
- An object that defines a scope where the given
Span
is set to the current context.
-
withSpan
static java.lang.Runnable withSpan(Span span, boolean endSpan, java.lang.Runnable runnable)
Wraps aRunnable
so that it executes with thespan
as the currentSpan
.- Parameters:
span
- theSpan
to be set as current.endSpan
- iftrue
the returnedRunnable
will close theSpan
.runnable
- theRunnable
to run in theSpan
.- Returns:
- the wrapped
Runnable
.
-
withSpan
static <C> java.util.concurrent.Callable<C> withSpan(Span span, boolean endSpan, java.util.concurrent.Callable<C> callable)
Wraps aCallable
so that it executes with thespan
as the currentSpan
.- Parameters:
span
- theSpan
to be set as current.endSpan
- iftrue
the returnedRunnable
will close theSpan
.callable
- theCallable
to run in theSpan
.- Returns:
- the wrapped
Callable
.
-
setErrorStatus
private static void setErrorStatus(Span span, java.lang.Throwable t)
-
-