Using Java annotations, APM Insight provides an easier way to custom instrument your application classes and methods. Usage of Java annotation enables you to define custom names for the transaction and also assign a custom component.
Prerequisites
This annotation can be used on Classes and Methods. When used upon a class, the attributes are applied for all the methods in that class. It will override the method-wise annotations.
Attributes:
component - Optional attribute
Defines the custom component for annotated classes/methods.
Example:
Case 1: Usage on Class
@ApmTracker
public class Category {
...
}
Case 2:
@ApmTracker(component="payment"
public class PaymentProcessor {
...
}
Case 3: Usage on Methods
public class Product {
@ApmTracker
public int getPrice(String product, String brand) {
...
}
...
@ApmTracker(component="FetchBrand")
private List fetchAllBrandsList(String product) {
...
}
}
name - Optional attribute
A custom name for the annotated element, which will be prepended to actual method name. Method parameters can be used for custom name by mentioning the argument index (starts at 1) with prefix '$'.
The instrumented methods and its custom names can be viewed under Traces.
This annotation can be used only on methods. If annotated method is the first method invoked on the server for processing the transaction, then the transaction is re-named using the value of the txnName attribute. Else, it is considered to be a normal method call and included in the traces.
Attributes:
component - Optional attribute
Defines the custom component for annotated methods.
name - Optional attribute
A custom name for the annotated element, which will be prepended to actual method name. Method parameters can be used for custom name by mentioning the argument index (starts at 1) with prefix '$'.
txnName - Mandatory attribute
Defines the name for the background transaction, only if the method is the entry point of the transaction else it will be tracked as generic method and added to the traces.
The transaction is named according to the value specified for the attribute txnName.