Package org.springframework.cloud.sleuth
Interface CurrentTraceContext
-
public interface CurrentTraceContextThis API was heavily influenced by Brave. Parts of its documentation were taken directly from Brave. This makes a given span the current span by placing it in scope (usually but not always a thread local scope).- Since:
- 3.0.0
- Author:
- OpenZipkin Brave Authors, Marcin Grzejszczak
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCurrentTraceContext.ScopeScope of a span.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TraceContextcontext()CurrentTraceContext.ScopemaybeScope(TraceContext context)LikenewScope(TraceContext), except returns a noop scope if the given context is already in scope.CurrentTraceContext.ScopenewScope(TraceContext context)Sets the current span in scope until the returned object is closed.Runnablewrap(Runnable task)Wraps a task in a trace representation.<C> Callable<C>wrap(Callable<C> task)Wraps a task in a trace representation.Executorwrap(Executor delegate)Wraps an executor in a trace representation.ExecutorServicewrap(ExecutorService delegate)Wraps an executor service in a trace representation.
-
-
-
Method Detail
-
context
@Nullable TraceContext context()
- Returns:
- current
TraceContextornullif not set.
-
newScope
CurrentTraceContext.Scope newScope(@Nullable TraceContext context)
Sets the current span in scope until the returned object is closed. It is a programming error to drop or never close the result. Using try-with-resources is preferred for this reason.- Parameters:
context- span to place into scope ornullto clear the scope- Returns:
- the scope with the span set
-
maybeScope
CurrentTraceContext.Scope maybeScope(@Nullable TraceContext context)
LikenewScope(TraceContext), except returns a noop scope if the given context is already in scope.- Parameters:
context- span to place into scope ornullto clear the scope- Returns:
- the scope with the span set
-
wrap
<C> Callable<C> wrap(Callable<C> task)
Wraps a task in a trace representation.- Type Parameters:
C- task return type- Parameters:
task- task to wrap- Returns:
- wrapped task
-
wrap
Runnable wrap(Runnable task)
Wraps a task in a trace representation.- Parameters:
task- task to wrap- Returns:
- wrapped task
-
wrap
Executor wrap(Executor delegate)
Wraps an executor in a trace representation.- Parameters:
delegate- executor to wrap- Returns:
- wrapped executor
-
wrap
ExecutorService wrap(ExecutorService delegate)
Wraps an executor service in a trace representation.- Parameters:
delegate- executor service to wrap- Returns:
- wrapped executor service
-
-