A basic sample probe

This example demonstrates some of the most commonly used parts of a probe definition.

In the example, the probe adds 1 to a counter each time a probed method is called. At the first call to a probed method and then at every 1000th method call, it uses System.out.println to show the counter value and the name of the method that caused the counter to roll over.

This probe is defined by the following entries in the Probekit editor:

  • Java code for Fragment At Class Scope (select Probe in the tree pane to enter this value):

    static public int entry_counter = 0;

  • Fragment (select Fragment in the tree pane to enter these values):
    • Fragment Type: entry
    • Data Items:
      • Data Type: className, Name: _class
      • Data Type: methodName, Name: _method
    • Java Code:

      if ((entry_counter % 1000) == 0)
               System.out.println("Counter value " + entry_counter +
                 " at a call to " + _class + "." + _method);
      entry_counter++;