Class AdditiveMetric
- All Implemented Interfaces:
Metric
For example, we might sample the byte size of each message we receive, and the AdditiveMetric will track a count of the number of times a sample has been taken, the total number of bytes received, and the number of messages sampled that exceeded certain limits. Another example is the amount of time that some operation takes.
The measured statistics can be compared against each other over a period of time to derive other statistics. For example, the total can be divided by the count to determine the average, or the number of samples over some limit may be divided by the count to determine the percentage of samples over that limit.
Metrics are intended to be sampled periodically and stored by some external component. Using that component to subtract some earlier time T1 from some later time T2 can provide statistics over that interval of time.
The sampled numbers are generally assumed to be positive; if negative numbers are used, it may become difficult for the consuming user to make certain inferences.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
emit
(Consumer<MetricValue> consumer) void
sample
(long n) Take the measurement.
-
Constructor Details
-
AdditiveMetric
-
-
Method Details
-
sample
public void sample(long n) Description copied from interface:Metric
Take the measurement. -
emit
- Specified by:
emit
in interfaceMetric
- Parameters:
consumer
- A callback receiving aMetricValue
that may be used to obtain the name and most recent value.
-