Interface Metric<T>

Type Parameters:
T - the type of value this metric holds

public interface Metric<T>
Represents a single telemetry data source.
  • Method Details

    • string

      static Metric<String> string(String name, Callable<String> supplier)
      Creates a new String metric.
      Parameters:
      name - the name of the metric
      supplier - the callable providing the value
      Returns:
      a new Metric instance returning a String
    • number

      static Metric<Number> number(String name, Callable<Number> supplier)
      Creates a new Number metric.
      Parameters:
      name - the name of the metric
      supplier - the callable providing the value
      Returns:
      a new Metric instance returning a Number
    • bool

      static Metric<Boolean> bool(String name, Callable<Boolean> supplier)
      Creates a new Boolean metric.
      Parameters:
      name - the name of the metric
      supplier - the callable providing the value
      Returns:
      a new Metric instance returning a Boolean
    • map

      static <V> Metric<Map<String,Object>> map(String name, Callable<Map<String,V>> supplier)
      Creates a new Map metric. Entry values are automatically normalized to standard supported types (Boolean, Number, String).
      Type Parameters:
      V - the original value type of the map
      Parameters:
      name - the name of the metric
      supplier - the callable providing the map
      Returns:
      a new Metric instance returning a normalized Map
    • collection

      static <E> Metric<Collection<Object>> collection(String name, Callable<Collection<E>> supplier)
      Creates a new Collection metric. Elements are automatically normalized to standard supported types (Boolean, Number, String).
      Type Parameters:
      E - the original element type of the collection
      Parameters:
      name - the name of the metric
      supplier - the callable providing the collection
      Returns:
      a new Metric instance returning a normalized Collection
    • array

      static <E> Metric<Object[]> array(String name, Callable<E[]> supplier)
      Creates a new Array metric. Elements are automatically normalized to standard supported types (Boolean, Number, String).
      Type Parameters:
      E - the original element type of the array
      Parameters:
      name - the name of the metric
      supplier - the callable providing the array
      Returns:
      a new Metric instance returning a normalized Array
    • getName

      String getName()
      Gets the unique name identifying this metric.
      Returns:
      the metric name
    • getValue

      T getValue() throws Exception
      Retrieves the current value of the metric.
      Returns:
      the collected value
      Throws:
      Exception - if data collection fails