Class CurrentSpanUtils


  • final class CurrentSpanUtils
    extends java.lang.Object
    Util methods/functionality to interact with the Span in the Context.
    • 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 The Span 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 given Span 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 a Runnable so that it executes with the span as the current Span.
      (package private) static <C> java.util.concurrent.Callable<C> withSpan​(Span span, boolean endSpan, java.util.concurrent.Callable<C> callable)
      Wraps a Callable so that it executes with the span as the current Span.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CurrentSpanUtils

        private CurrentSpanUtils()
    • Method Detail

      • getCurrentSpan

        @Nullable
        static Span getCurrentSpan()
        Returns The Span 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 given Span 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 - The Span to be set to the current context.
        endSpan - if true the returned Scope will close the Span.
        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 a Runnable so that it executes with the span as the current Span.
        Parameters:
        span - the Span to be set as current.
        endSpan - if true the returned Runnable will close the Span.
        runnable - the Runnable to run in the Span.
        Returns:
        the wrapped Runnable.
      • withSpan

        static <C> java.util.concurrent.Callable<C> withSpan​(Span span,
                                                             boolean endSpan,
                                                             java.util.concurrent.Callable<C> callable)
        Wraps a Callable so that it executes with the span as the current Span.
        Parameters:
        span - the Span to be set as current.
        endSpan - if true the returned Runnable will close the Span.
        callable - the Callable to run in the Span.
        Returns:
        the wrapped Callable.
      • setErrorStatus

        private static void setErrorStatus​(Span span,
                                           java.lang.Throwable t)