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
, a
java.math.BigDecimal
or a primitive wrapper instance like java.lang.Integer
or java.lang.Double
.
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 by 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.
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".
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionOptional display options for the telemetry.The optional line name of the telemetry.
-
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.jprofiler.api.probe.injected.telemetry.TelemetryFormat
-