Package jetbrains.buildServer.util
Class IntervalMetric
- java.lang.Object
-
- jetbrains.buildServer.util.IntervalMetric
-
public class IntervalMetric extends Object
This class holds N last values for some metric gathered during specified intervals. For instance, if there is some metric, like number of bytes written to disk, instance of this class can be created to hold values for this metric during the last 1, 5 and 10 minutes.- Since:
- 9.1.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IntervalMetric.ValueType
Represents type of the metric.
-
Field Summary
Fields Modifier and Type Field Description static long[]
DEFAULT_INTERVALS
-
Constructor Summary
Constructors Constructor Description IntervalMetric(String description)
Creates metric with some human readable descriptionIntervalMetric(IntervalMetric.ValueType valueType, long[] intervals, String description, TimeService timeService)
Creates metric.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(long amount)
Adds specified amount to the metricString
getDescription()
List<String>
getFormattedRate()
long
getLastModified()
List<Float>
getRate()
long
getValue(int idx)
Returns value of the metric for given interval index.
-
-
-
Constructor Detail
-
IntervalMetric
public IntervalMetric(@NotNull String description)
Creates metric with some human readable description- Parameters:
description
- description of the metric
-
IntervalMetric
public IntervalMetric(@NotNull IntervalMetric.ValueType valueType, long[] intervals, @NotNull String description, @Nullable TimeService timeService)
Creates metric.- Parameters:
valueType
- metric type,IntervalMetric.ValueType
intervals
- a number of intervals for this metric, each value of this array is time in millisecondsdescription
- human readable descriptiontimeService
- time service, it will be used to obtain current time; can be null, useful for tests
-
-
Method Detail
-
add
public void add(long amount)
Adds specified amount to the metric- Parameters:
amount
- amount to add
-
getValue
public long getValue(int idx)
Returns value of the metric for given interval index. Returns 0 if specified interval is not yet passed.- Parameters:
idx
- index of the interval in interval array- Returns:
- see above
-
getLastModified
public long getLastModified()
- Returns:
- time when add with positive amount was called last time, can be 0 if this never happened
-
getRate
@NotNull public List<Float> getRate()
- Returns:
- list of current rate of the metric (amount per second) for all time intervals
-
getFormattedRate
@NotNull public List<String> getFormattedRate()
- Returns:
- list of formatted rate of the metric for all time intervals
-
getDescription
@NotNull public String getDescription()
- Returns:
- metric description
-
-