Interface PluginMetrics
public interface PluginMetrics
This allows plugins to register metrics and sensors. Any metrics registered by the plugin are automatically removed when the plugin closed.
Method Summary
Modifier and TypeMethodDescriptionvoidaddMetric(MetricName metricName, MetricValueProvider<?> metricValueProvider) Add a metric to monitor an object that implementsMetricValueProvider.Create aSensorwith the given unique name.metricName(String name, String description, LinkedHashMap<String, String> tags) Create aMetricNamewith the given name, description and tags.voidremoveMetric(MetricName metricName) Remove a metric if it exists.voidremoveSensor(String name) Remove aSensorand its associated metrics.
Method Details
metricName
Create aMetricNamewith the given name, description and tags. The group will be set to "plugins" Tags to uniquely identify the plugins are automatically added to the provided tags- Parameters:
name- The name of the metricdescription- A human-readable description to include in the metrictags- Additional tags for the metric- Throws:
IllegalArgumentException- if any of the tag names collide with the default tags for the plugin
addMetric
Add a metric to monitor an object that implementsMetricValueProvider. This metric won't be associated with any sensor. This is a way to expose existing values as metrics.- Parameters:
metricName- The name of the metricmetricValueProvider- The metric value provider associated with this metric- Throws:
IllegalArgumentException- if a metric with same name already exists
removeMetric
Remove a metric if it exists.- Parameters:
metricName- The name of the metric- Throws:
IllegalArgumentException- if a metric with this name does not exist
addSensor
Create aSensorwith the given unique name. The name must only be unique for the plugin, so different plugins can use the same names.- Parameters:
name- The sensor name- Returns:
- The sensor
- Throws:
IllegalArgumentException- if a sensor with same name already exists for this plugin
removeSensor
Remove aSensorand its associated metrics.- Parameters:
name- The name of the sensor to be removed- Throws:
IllegalArgumentException- if a sensor with this name does not exist