Annotation Interface Telemetry
Only public static parameterless methods can be used for creating custom telemetries, annotating instance methods or non-public
static methods will not have any effect.
The method must return a numeric value, either a primitive value like int
or double
or a
primitive wrapper instance like java.lang.Integer
or java.lang.Double
.
It is not enough if the class containing the annotated method is present in the classpath. You have to make sure that the class is loaded at runtime, so perfino can intercept the class loading event and set up the custom telemetry.
The method is called periodically on a dedicated thread. This may have implications for the requirements of
thread safety in your code. If the numeric value is calculated on the fly, access to the data structures
must be made thread-safe by making access to those data structures synchronized. Alternatively, you could
calculate a cached value when convenient and save it to a volatile atomic value, like an int
or a
class from the java.util.concurrent.atomic
package.
In the perfino UI, the telemetry is shown in the VM data views under "Custom telemetries" together with the MBean telemetries that are defined in the recording settings. In addition, you can choose custom telemetries as data sources for sparklines in the dashboard or in the VMs view.
For example, the following code snippet defines a custom telemetry with the name "Connection count":
@Telemetry("Connection count") public static int getConnectionCount() { return connectionCount; }
Multiple lines in a single custom telemetry
If you want to compare several measurements in the same telemetry, you can annotate multiple methods with the
same value()
for the telemetry name, but with a different line()
parameter.
For example:
@Telemetry(value = "Queries", line = "Successful queries") public static int getSuccessCount() { return successCount; } @Telemetry(value = "Queries", line = "Failed queries") public static int getErrorCount() { return errorCount; }
This will create a single custom telemetry with the name "Queries" and two data lines named "Successful queries" and "Failed queries".
-
Element Details
-
value
String valueThe name of the telemetry. Give different names to different telemetries. Reuse the same name when annotating different methods if you are creating a custom telemetry with multiple lines. If only a single line is used, you can omit the "value" parameter name, as in@Telemetry("Connection count")
-
line
String lineThe optional line name of the telemetry. Only specify this parameter if you're creating a telemetry with multiple lines. SeeTelemetry
for an example.- Default:
""
-
format
TelemetryFormat formatOptional display options for the telemetry.- Default:
@com.perfino.annotation.TelemetryFormat
-