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:
1.0.0
  • Field Details

  • Method Details

    • context

      @Nullable TraceContext context()
      Returns:
      current TraceContext or null 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 or null to clear the scope
      Returns:
      the scope with the span set
    • maybeScope

      CurrentTraceContext.Scope maybeScope(@Nullable TraceContext context)
      Like newScope(TraceContext), except returns a noop scope if the given context is already in scope.
      Parameters:
      context - span to place into scope or null 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

      Wraps an executor service in a trace representation.
      Parameters:
      delegate - executor service to wrap
      Returns:
      wrapped executor service