Class StatMetric
java.lang.Object
com.inductiveautomation.ignition.common.StatMetric
- All Implemented Interfaces:
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:
- Total
- Average Duration
- Max Duration
- Min Duration
- Throughput
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreates a StatMetric that tracks averages in TimeUnit.SECONDS.StatMetric
(TimeUnit timeUnit) StatMetric
(TimeUnit timeUnit, int nRequiredForAverage) -
Method Summary
Modifier and TypeMethodDescriptiondouble
getAvg()
The average duration (in seconds) for this metric.long
getHits()
Deprecated.double
getLast()
The last duration in seconds.long
The last timestamp that this statmetric was updated.double
getMax()
The maximum duration (in seconds) ever witnessed for this metric.getMetric
(StatMetric.Metric metric) double
getMin()
The minimum duration (in seconds) ever witnessed for this metric.double
The current throughput for this metric (hits/second), or -1 if the metric is idle.long
getTotal()
The total number of occurrences for this metric.static void
protected void
onSetThroughput
(double throughput) Called when the throughput is updated.void
setTimeBetweenThroughputCalcs
(int timeBetweenThroughputCalcs) Set the amount of time that must pass between successive calculations of the throughput.void
setTimeUnit
(TimeUnit timeUnit) toString()
void
update
(long startTime) void
update
(long startTime, int count)
-
Constructor Details
-
StatMetric
public StatMetric()Creates a StatMetric that tracks averages in TimeUnit.SECONDS. -
StatMetric
- Parameters:
timeUnit
- TimeUnit to use. Only TimeUnit.MILLISECONDS or TimeUnit.SECONDS.
-
StatMetric
- 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. -
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
-
setTimeUnit
-
getMetric
-
toString
-
main
-