@ThingworxExtensionApiClass(since={8,1,1}, canInstantiate=true) public class Metrics extends java.lang.Object
Metrics are tracked through a concurrent-safe registry. A metric should be used to track important information that is useful for diagnostics and performance monitoring. All metrics requested must be specified by a key. All metric keys should be appropriately namespaced to avoid potential collisions with other code. For example, the following keys would be appropriate for an extension:
There are five types of metrics you can create:
The typical use of metrics would be similar to:
Metrics.longValue().counter("ExampleApp.ExampleTemplate.TheService.invokeCount").incr();
Metrics are persisted across server restarts. It is not necessary to store metric values in a persisted environment, such as a property.
Note: A metric can only be of one type. If you attempt to get a metric key that was created via a different type, an
IllegalArgumentException
will be thrown.
Constructor and Description |
---|
Metrics() |
Modifier and Type | Method and Description |
---|---|
static IBooleanMetricBuilder |
bool()
Provides access to a Boolean metric. |
static IBasicMetricBuilder<org.joda.time.DateTime> |
dateTime()
Provides access to a DateTime metric. |
static ILongMetricBuilder |
longValue()
Provides access to a Long metric. |
static java.lang.String |
name(java.lang.String... components)
Generates the name for a metric using the specified components. |
static IBasicMetricBuilder<java.lang.Double> |
number()
Provides access to a Number metric (a.k.a. |
static IBasicMetricBuilder<java.lang.String> |
string()
Provides access to a String metric. |
@ThingworxExtensionApiMethod(since={8,1,1}) public static IBooleanMetricBuilder bool()
@ThingworxExtensionApiMethod(since={8,1,1}) public static IBasicMetricBuilder<java.lang.Double> number()
@ThingworxExtensionApiMethod(since={8,1,1}) public static IBasicMetricBuilder<org.joda.time.DateTime> dateTime()
@ThingworxExtensionApiMethod(since={8,1,1}) public static IBasicMetricBuilder<java.lang.String> string()
@ThingworxExtensionApiMethod(since={8,1,1}) public static ILongMetricBuilder longValue()
@ThingworxExtensionApiMethod(since={8,1,1}) public static java.lang.String name(java.lang.String... components)
components
- one or more strings describing the metric