Annotation Transactions

Many frameworks use annotations for designating important classes and entry points that could be turned into transactions in perfino. With the "Annotated invocations" transaction type you can let perfino do this work for you.

Method and class annotations

An annotation transaction definition takes the fully qualified class name of the annotation that you are interested in. Annotations can be either used on classes or on methods. Before proceeding with the configuration, you have to tell perfino for which target the selected annotation is used.

For an annotated method, each method invocation becomes a transaction in perfino. Annotations on classes create transactions for all calls into public instance methods.

The second choice is whether derived classes should be considered as well. For methods, it can be important to capture the time in an overridden method. For example, if a framework creates an implementing proxy class and overrides the annotated method in order to add database transactions, you want to intercept the method in the proxy class, and not only the annotated method.

For annotated classes, the "Method selection" options determine which methods are selected to generate transactions:


When you use annotations on classes with the setting for intercepting public methods in derived classes, the question remains what class name should be used in the transaction naming.

By default, a naming element of type "Class name" adds the name of the class where the intercepted method is defined. If you want to add the name of the annotated super class instead, select the "Use annotated class name for filter and naming" check box in the "Annotation" step of the wizard.

If you want to go the other way and add the class name of the actual instance on which the method was called, use the "Instance class name" naming element instead.

Even more specific, the "Instance name" naming element adds the toString() invocation on the object where the transaction method was called.

This naming element can also apply a getter chain to this object and append the toString() invocation on the result to the transaction name instead. For example, if the instance class has a getVerbose() method that returns the desired text, set the getter chain to getVerbose(). You can mix public field accesses and parameter-less invocations of public methods like this:


If you use the getClass() method to append a class name, there are two special fields that are provided by perfino to simulate the abbreviated and simple class name modes that are available for the "Class name" and "Instance class name" naming elements:

Note that the "Instance name" naming element generates a far higher overhead than the "Instance class name" or "Class name" naming elements, since it always involves actual method calls.