Class Metric

java.lang.Object
org.apache.pekko.cluster.metrics.Metric
All Implemented Interfaces:
Serializable, MetricNumericConverter, scala.Equals, scala.Product

public final class Metric extends Object implements MetricNumericConverter, scala.Product, Serializable
Metrics key/value.

Equality of Metric is based on its name.

param: name the metric name param: value the metric value, which must be a valid numerical value, a valid value is neither negative nor NaN/Infinite. param: average the data stream of the metric value, for trending over time. Metrics that are already averages (e.g. system load average) or finite (e.g. as number of processors), are not trended.

See Also:
  • Method Details

    • create

      public static scala.Option<Metric> create(String name, Number value, scala.Option<Object> decayFactor)
      Creates a new Metric instance if the value is valid, otherwise None is returned. Invalid numeric values are negative and NaN/Infinite.
    • create

      public static scala.Option<Metric> create(String name, scala.util.Try<Number> value, scala.Option<Object> decayFactor)
      Creates a new Metric instance if the Try is successful and the value is valid, otherwise None is returned. Invalid numeric values are negative and NaN/Infinite.
    • createEWMA

      public static scala.Option<EWMA> createEWMA(double value, scala.Option<Object> decayFactor)
    • apply

      public static Metric apply(String name, Number value, scala.Option<EWMA> average)
    • unapply

      public static scala.Option<scala.Tuple3<String,Number,scala.Option<EWMA>>> unapply(Metric x$0)
    • defined

      public static boolean defined(Number value)
    • convertNumber

      public static scala.util.Either<Object,Object> convertNumber(Object from)
    • name

      public String name()
    • value

      public Number value()
    • average

      public scala.Option<EWMA> average()
    • $colon$plus

      public Metric $colon$plus(Metric latest)
      Updates the data point, and if defined, updates the data stream (average). Returns the updated metric.
    • smoothValue

      public double smoothValue()
      The numerical value of the average, if defined, otherwise the latest value
    • isSmooth

      public boolean isSmooth()
      Returns:
      true if this value is smoothed
    • sameAs

      public boolean sameAs(Metric that)
      Returns true if that is tracking the same metric as this.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface scala.Equals
      Overrides:
      equals in class Object
    • copy

      public Metric copy(String name, Number value, scala.Option<EWMA> average)
    • copy$default$1

      public String copy$default$1()
    • copy$default$2

      public Number copy$default$2()
    • copy$default$3

      public scala.Option<EWMA> copy$default$3()
    • productPrefix

      public String productPrefix()
      Specified by:
      productPrefix in interface scala.Product
    • productArity

      public int productArity()
      Specified by:
      productArity in interface scala.Product
    • productElement

      public Object productElement(int x$1)
      Specified by:
      productElement in interface scala.Product
    • productIterator

      public scala.collection.Iterator<Object> productIterator()
      Specified by:
      productIterator in interface scala.Product
    • canEqual

      public boolean canEqual(Object x$1)
      Specified by:
      canEqual in interface scala.Equals
    • productElementName

      public String productElementName(int x$1)
      Specified by:
      productElementName in interface scala.Product
    • toString

      public String toString()
      Overrides:
      toString in class Object