Class Tracing

java.lang.Object
com.peterphi.std.util.tracing.Tracing

public final class Tracing extends Object
  • Field Details

    • DEFAULT_VERBOSE

      public static boolean DEFAULT_VERBOSE
    • id

      public String id
    • ops

      public int ops
    • verbose

      public boolean verbose
  • Method Details

    • peek

      public static Tracing peek()
    • get

      public static Tracing get()
    • stop

      public static void stop(String id)
    • clear

      public static void clear()
    • start

      public static void start(String id)
    • start

      public static void start(String id, boolean verbose)
    • newOperationId

      public static String newOperationId()
      Allocate an operation ID within a tracing block, returning null if we are not within a tracing block
      Returns:
    • wrap

      public static <T, R> Function<T,R> wrap(Function<T,R> function)
      Wrap a function call in a trace block; designed for use in a parallel stream
      Type Parameters:
      T - the type of the input to the function
      R - the type of the result of the function
      Returns:
    • wrap

      public static <T, R> Function<T,R> wrap(String id, boolean verbose, Function<T,R> function)
      Wrap a function call in a trace block; designed for use in a parallel stream
      Type Parameters:
      T - the type of the input to the function
      R - the type of the result of the function
      Returns:
    • log

      public static String log(String name, Supplier<String> detail)
    • log

      public static String log(Object... detail)
      If verbose tracing is enabled, log an operation
      Parameters:
      detail - an array of items; will be reduced to String and concatenated together; if a Supplier is in the list, it will be invoked
      Returns:
      an operation identifier (if we're within a tracing block)
    • logOngoing

      public static void logOngoing(String operationId, String name, Object... detail)
      Log an additional message about an ongoing operation
      Parameters:
      operationId - the operation id returned by either log(String, Supplier) or newOperationId()
      name -
      detail -
    • getTraceId

      public static String getTraceId()
    • isVerbose

      public static boolean isVerbose()