@Retention(value=RUNTIME)
@Target(value=METHOD)
public @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".
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
value
The name of the telemetry.
|
Modifier and Type | Optional Element and Description |
---|---|
TelemetryFormat |
format
Optional display options for the telemetry.
|
java.lang.String |
line
The optional line name of the telemetry.
|
public abstract java.lang.String value
@Telemetry("Connection count")
public abstract java.lang.String line
Telemetry
for an example.public abstract TelemetryFormat format