Using Java annotations, APM Insight provides an easier way to custom-instrument your application classes and methods. By using Java annotations, you can define custom names for transactions and assign them to specific components.
This annotation can be used on classes and methods.
When applied at the class level, the specified attributes are inherited by all methods in the class, overriding any method-level annotations. The annotation supports the following attributes:
Specifies a custom component name for the annotated class or method.
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) {
...
}
}
Defines a custom name for the annotated method. This name will be prepended to the actual method name in the trace. You can include method parameters in the name by referencing the argument index using the $ prefix (e.g., $1, $2, etc., where indexing starts at 1).
The instrumented methods and their custom names will be displayed under Traces in Applications Manager.
This annotation can be used only on methods.
If the annotated method is the first method invoked on the server to process a transaction, the transaction is renamed using the value of the txnName attribute. Otherwise, it is treated as a regular method call and is included in the trace. The supported attributes are:
Specifies a custom component for the annotated method.
Defines a custom name for the annotated method. This name will be prepended to the actual method name in the trace.
You can also include method parameters by referencing their index using the $ prefix (e.g., $1, $2, etc., with indexing starting at 1).
Specifies the name for the background transaction only if the annotated method is the entry point of the transaction.
If the method is not the entry point, it is tracked as a normal method and added to the trace accordingly.
The transaction will be named based on the value provided for the txnName attribute.
Thank you for your feedback!