Class MetricsFactory


  • @ThreadSafe
    public final class MetricsFactory
    extends java.lang.Object
    A Metrics factory.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Metrics NULL_METRICS
      A "do-nothing" Metrics instance.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Metrics getInstance​(java.lang.String name, int estimationSize, long estimationTime, double smoothing, double threshold)
      Creates a Metrics instance.
      static Metrics getInstance​(org.w3c.dom.Element element)
      Creates a Metrics instance based on element attributes.
      static Metrics getMetric​(java.lang.String name)
      Returns an existing Metric instance with the specified name.
      static java.util.Collection<Metrics> getMetrics()
      Returns all Metric instances, sorted by name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NULL_METRICS

        public static final Metrics NULL_METRICS
        A "do-nothing" Metrics instance.
    • Method Detail

      • getInstance

        public static Metrics getInstance​(org.w3c.dom.Element element)
        Creates a Metrics instance based on element attributes. If an instance with the same name already exists, it will be returned.
        Element Attributes
        Attribute NameRequirementsDescriptionNotes
        name Required The metric name.  
        estimation-size Optional Positive integer number of events to include in the metrics calculation. Defaults to "100".
        estimation-time Optional Positive integer number of milliseconds to include in the metrics calculation. Defaults to "1000".
        smoothing Optional Smoothing factor - used to smooth the differences between calculations. A value of "1" disables smoothing. Defaults to "0.7".
        threshold Optional The metric threshold. The meaning of the threshold is determined by client code. Defaults to "0.0".
        Parameters:
        element - The element whose attributes will be used to create the Metrics instance
        Returns:
        A Metrics instance based on element attributes
        Throws:
        java.lang.IllegalArgumentException - if element is null or if the name attribute is empty
        java.lang.NumberFormatException - if any of the numeric attribute values are unparsable
      • getInstance

        public static Metrics getInstance​(java.lang.String name,
                                          int estimationSize,
                                          long estimationTime,
                                          double smoothing,
                                          double threshold)
        Creates a Metrics instance. If an instance with the same name already exists, it will be returned.
        Parameters:
        name - The metric name.
        estimationSize - Positive integer number of events to include in the metrics calculation.
        estimationTime - Positive integer number of milliseconds to include in the metrics calculation.
        smoothing - Smoothing factor - used to smooth the differences between calculations.
        Returns:
        A Metrics instance
      • getMetric

        public static Metrics getMetric​(java.lang.String name)
        Returns an existing Metric instance with the specified name. Returns null if the metric does not exist.
        Parameters:
        name - The metric name
      • getMetrics

        public static java.util.Collection<Metrics> getMetrics()
        Returns all Metric instances, sorted by name.