Class Metrics


  • public class Metrics
    extends java.lang.Object
    API for recording custom metrics. Recorded metrics will be aggregated and submitted periodically
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String HOST_TAG_KEY  
    • Constructor Summary

      Constructors 
      Constructor Description
      Metrics()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void incrementMetric​(java.lang.String name, int count, boolean addHostTag, java.util.Map<java.lang.String,​java.lang.String> tags)
      Records a Count metrics that increments by the count parameter Count metrics will be aggregated by the key- combination of metric name and tags, with a count (sum of count from each call with same key).
      static void incrementMetric​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.String> tags)
      Records a Count Metrics that increments by 1 Count metrics will be aggregated by the key- combination of metric name and tags, with a count (sum of count from each call with same key, default as 1).
      static void summaryMetric​(java.lang.String name, double value, int count, boolean addHostTag, java.util.Map<java.lang.String,​java.lang.String> tags)
      Records a Summary Metric which consists of a single value and a count.
      static void summaryMetric​(java.lang.String name, double value, java.util.Map<java.lang.String,​java.lang.String> tags)
      Records a Summary Metric which consists of a single value.
      • Methods inherited from class java.lang.Object

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

      • Metrics

        public Metrics()
    • Method Detail

      • summaryMetric

        public static void summaryMetric​(java.lang.String name,
                                         double value,
                                         java.util.Map<java.lang.String,​java.lang.String> tags)
        Records a Summary Metric which consists of a single value. Summary metrics will be aggregated by the key- combination of metric name and tags, with a sum (sum of value from each call with same key), and a count (sum of count from each call with same key, with by default is 1 per call).
        Parameters:
        name - a custom name for this Summary Metric
        value - a double value for this Summary Metric
        tags - a Map of custom tags for this Summary Metric
      • summaryMetric

        public static void summaryMetric​(java.lang.String name,
                                         double value,
                                         int count,
                                         boolean addHostTag,
                                         java.util.Map<java.lang.String,​java.lang.String> tags)
        Records a Summary Metric which consists of a single value and a count. Summary metrics will be aggregated by the key- combination of metric name and tags, with a sum (sum of value from each call with same key), and a count (sum of count from each call with same key). This is a more efficient method to record metrics with same key. For example, if a Summary Metric is to be recorded for an operation performed repeatedly, then a total duration can be first accumulated with a count and passed to this method once instead of calling this repeatedly for each operation.
        Parameters:
        name - a custom name for this Summary Metric
        value - a double value for this Summary Metric, take note that this should be an accumulative value if count is greater than 1
        count - a count of measured operations that produce the accumulative value
        addHostTag - whether tag the Summary Metric with host information
        tags - a Map of custom tags for this Summary Metric
      • incrementMetric

        public static void incrementMetric​(java.lang.String name,
                                           java.util.Map<java.lang.String,​java.lang.String> tags)
        Records a Count Metrics that increments by 1 Count metrics will be aggregated by the key- combination of metric name and tags, with a count (sum of count from each call with same key, default as 1).
        Parameters:
        name - a custom name for this Count Metric
        tags - a Map of custom tags for Count Metric
      • incrementMetric

        public static void incrementMetric​(java.lang.String name,
                                           int count,
                                           boolean addHostTag,
                                           java.util.Map<java.lang.String,​java.lang.String> tags)
        Records a Count metrics that increments by the count parameter Count metrics will be aggregated by the key- combination of metric name and tags, with a count (sum of count from each call with same key). This is a more efficient method to record metrics with same key. For example, if a Count Metric is to be recorded for an operation performed repeatedly, then an accumulated count can be passed to this method once instead of calling this repeatedly for each operation.
        Parameters:
        name - a custom name for this Count Metric
        count - a accumulative count of operations
        addHostTag - whether tag the Count Metric with host information
        tags - a Map of custom tags for Count Metric