Class StatMetric

java.lang.Object
com.inductiveautomation.ignition.common.StatMetric
All Implemented Interfaces:
Serializable

@ThreadSafe public class StatMetric extends Object implements Serializable
A StatMetric keeps track of various statistics for one metric. For instance, the Metric might be "Requests". The statistics that can be kept are:
  1. Total
  2. Average Duration
  3. Max Duration
  4. Min Duration
  5. Throughput
See Also:
  • Constructor Details

    • StatMetric

      public StatMetric()
      Creates a StatMetric that tracks averages in TimeUnit.SECONDS.
    • StatMetric

      public StatMetric(TimeUnit timeUnit)
      Parameters:
      timeUnit - TimeUnit to use. Only TimeUnit.MILLISECONDS or TimeUnit.SECONDS.
    • StatMetric

      public StatMetric(TimeUnit timeUnit, int nRequiredForAverage)
      Parameters:
      timeUnit - TimeUnit to use. Only TimeUnit.MILLISECONDS or TimeUnit.SECONDS.
      nRequiredForAverage - The number of calls to update() required to compute an average. Once reached, the average is computed using the last N values.
  • Method Details

    • setTimeBetweenThroughputCalcs

      public void setTimeBetweenThroughputCalcs(int timeBetweenThroughputCalcs)
      Set the amount of time that must pass between successive calculations of the throughput.
    • update

      public void update(long startTime)
    • update

      public void update(long startTime, int count)
    • onSetThroughput

      protected void onSetThroughput(double throughput)
      Called when the throughput is updated. Override if desired.
    • getAvg

      public double getAvg()
      The average duration (in seconds) for this metric.
    • getHits

      @Deprecated public long getHits()
      Deprecated.
    • getTotal

      public long getTotal()
      The total number of occurrences for this metric.
    • getMax

      public double getMax()
      The maximum duration (in seconds) ever witnessed for this metric.
    • getMin

      public double getMin()
      The minimum duration (in seconds) ever witnessed for this metric.
    • getLast

      public double getLast()
      The last duration in seconds.
    • getThroughput

      public double getThroughput()
      The current throughput for this metric (hits/second), or -1 if the metric is idle.
    • getLastUpdate

      public long getLastUpdate()
      The last timestamp that this statmetric was updated.
      Returns:
      The last System.currentTimeMillis() that this StatMetric had update() called on it.
    • getTimeUnit

      public TimeUnit getTimeUnit()
    • setTimeUnit

      public void setTimeUnit(TimeUnit timeUnit)
    • getMetric

      public Object getMetric(StatMetric.Metric metric)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • main

      public static void main(String[] args)