Package org.springframework.cloud.sleuth
Interface CurrentTraceContext
-
public interface CurrentTraceContext
This 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 interface
CurrentTraceContext.Scope
Scope of a span.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TraceContext
context()
CurrentTraceContext.Scope
maybeScope(TraceContext context)
LikenewScope(TraceContext)
, except returns a noop scope if the given context is already in scope.CurrentTraceContext.Scope
newScope(TraceContext context)
Sets the current span in scope until the returned object is closed.Runnable
wrap(Runnable task)
Wraps a task in a trace representation.<C> Callable<C>
wrap(Callable<C> task)
Wraps a task in a trace representation.Executor
wrap(Executor delegate)
Wraps an executor in a trace representation.ExecutorService
wrap(ExecutorService delegate)
Wraps an executor service in a trace representation.
-
-
-
Method Detail
-
context
@Nullable TraceContext context()
- Returns:
- current
TraceContext
ornull
if 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 ornull
to 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 ornull
to 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
-
-