- All Implemented Interfaces:
public class Frequencies extends SampledStat implements CompoundStat
CompoundStatthat represents a normalized distribution with a
Frequencymetric for each bucketed value. The values of the
Frequencymetrics specify the frequency of the center value appearing relative to the total number of values recorded.
For example, consider a component that records failure or success of an operation using boolean values, with one metric to capture the percentage of operations that failed another to capture the percentage of operations that succeeded.
This can be accomplish by created a
Sensor to record the values,
with 0.0 for false and 1.0 for true. Then, create a single
Frequencies object that has two
Frequency metrics: one centered around 0.0 and another centered around 1.0. The
object is a
CompoundStat, and so it can be
added directly to a Sensor so the metrics are created automatically.
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.kafka.common.metrics.stats.SampledStat
Constructors Constructor Description
Frequency... frequencies)(int buckets, double min, double max,Create a Frequencies that captures the values in the specified range into the given number of buckets, where the buckets are centered around the minimum, maximum, and intermediate values.
Modifier and Type Method Description
List<SampledStat.Sample> samples, MetricConfig config, long now)(
MetricName falseMetricName, MetricName trueMetricName)(Create a Frequencies instance with metrics for the frequency of a boolean sensor that records 0.0 for false and 1.0 for true.
MetricConfig config, long now, double centerValue)(Return the computed frequency describing the number of occurrences of the values in the bucket for the given center point, relative to the total number of occurrences in the samples.
SampledStat.Sample sample, MetricConfig config, double value, long timeMs)(
Methods inherited from class org.apache.kafka.common.metrics.stats.SampledStat
current, measure, oldest, purgeObsoleteSamples, record, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Frequenciespublic Frequencies(int buckets, double min, double max, Frequency... frequencies)Create a Frequencies that captures the values in the specified range into the given number of buckets, where the buckets are centered around the minimum, maximum, and intermediate values.
buckets- the number of buckets; must be at least 1
min- the minimum value to be captured
max- the maximum value to be captured
frequencies- the list of
Frequencymetrics, which at most should be one per bucket centered on the bucket's value, though not every bucket need to correspond to a metric if the value is not needed
IllegalArgumentException- if any of the
Frequencyobjects do not have a
center valuewithin the specified range
forBooleanValuesCreate a Frequencies instance with metrics for the frequency of a boolean sensor that records 0.0 for false and 1.0 for true.
falseMetricName- the name of the metric capturing the frequency of failures; may be null if not needed
trueMetricName- the name of the metric capturing the frequency of successes; may be null if not needed
- the Frequencies instance; never null
IllegalArgumentException- if both
frequencypublic double frequency(MetricConfig config, long now, double centerValue)Return the computed frequency describing the number of occurrences of the values in the bucket for the given center point, relative to the total number of occurrences in the samples.
config- the metric configuration
now- the current time in milliseconds
centerValue- the value corresponding to the center point of the bucket
- the frequency of the values in the bucket relative to the total number of samples
newSampleprotected org.apache.kafka.common.metrics.stats.Frequencies.HistogramSample newSample(long timeMs)