Class Split

java.lang.Object
com.jprofiler.api.probe.embedded.Split

public class Split extends Object
By calling this class you can add an arbitrary split in the call tree, just like the URL splitting of JProfiler's built-in "HTTP Server" probe.

You can either use a pair of enter(Class, String) and exit() calls or the two execute wrappers. If you write your own wrapper in another JVM language it is advisable to use the enter(Class, String) and exit() primitives.

When using the primitives, it is very important that a matching exit() is always called, so the exit call must be put it a finally block like this:


     Split.enter(MyProbe.class, "my split string");
     try {
         // your code
     } finally {
         Split.exit();
     }
 
  • Constructor Details

    • Split

      public Split()
  • Method Details

    • enter

      public static void enter(Class<? extends SplitProbe> probe, String name)
      Split the call tree with the given name. A matching exit() call must be always called.
      Parameters:
      probe - the configuration class. Must not be null.
      name - the line that should show up in the call tree. If null, the call tree won't be split.
    • exit

      public static void exit()
      Marks the end of a split. A matching enter(Class, String) call must have been called first.
    • execute

      public static void execute(Class<? extends SplitProbe> probe, String name, Runnable runnable)
      A wrapper for the enter(Class, String) and exit() primitives for a Runnable.
      Parameters:
      probe - the configuration class. Must not be null.
      name - the line that should show up in the call tree. If null, the call tree won't be split.
      runnable - the runnable that will be executed inside the split.
    • execute

      public static <T> T execute(Class<? extends SplitProbe> probe, String name, Callable<T> callable) throws Exception
      A wrapper for the enter(Class, String) and exit() primitives for a Callable.
      Parameters:
      probe - the configuration class. Must not be null.
      name - the line that should show up in the call tree. If null, the call tree won't be split.
      callable - the callable that will be executed inside the split.
      Throws:
      Exception
    • register

      public static void register(Class<? extends SplitProbe> probe)
      You can register your probe independently of enter(Class, String) and execute calls. As soon as the probe is registered it will be displayed in the JProfiler UI and telemetries can be recorded. You don't have to call this method if you don't want to start telemetry recording before an enter(Class, String) or execute call takes place. enter(Class, String) or execute will automatically register your probe.
      Parameters:
      probe - the configuration class. Must not be null.