This example demonstrates how to use the fragment at class scope in a probe.
In the example, a probe counts the number of instances ever created of all classes in packages matching the com.sample* wildcard pattern, and reports every hundredth instance creation.
The fragment at class scope declares a counter that appears as an int-type static field in the class that the entry fragment is compiled into. The fragment also declares a static initializer for the fragment class to report that the probe has been loaded. Note that the items in the fragment at class scope are built into the generated probe class, not into the classes that the probe applies to. To insert static fields or static initializer logic into classes that a probe applies to, use probe fragments of the type staticInitializer, or define a static field.