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 Details

    • metricName

      MetricName metricName(String name, String description, LinkedHashMap<String,String> tags)
      Create a MetricName with 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 metric
      description - A human-readable description to include in the metric
      tags - Additional tags for the metric
      Throws:
      IllegalArgumentException - if any of the tag names collide with the default tags for the plugin
    • addMetric

      void addMetric(MetricName metricName, MetricValueProvider<?> metricValueProvider)
      Add a metric to monitor an object that implements MetricValueProvider. 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 metric
      metricValueProvider - The metric value provider associated with this metric
      Throws:
      IllegalArgumentException - if a metric with same name already exists
    • removeMetric

      void removeMetric(MetricName metricName)
      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

      Sensor addSensor(String name)
      Create a Sensor with 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

      void removeSensor(String name)
      Remove a Sensor and its associated metrics.
      Parameters:
      name - The name of the sensor to be removed
      Throws:
      IllegalArgumentException - if a sensor with this name does not exist