Class KafkaMetricHistogram

java.lang.Object
io.confluent.kafka.replication.push.metrics.KafkaMetricHistogram
All Implemented Interfaces:
org.apache.kafka.common.metrics.CompoundStat, org.apache.kafka.common.metrics.Stat

public final class KafkaMetricHistogram extends Object implements org.apache.kafka.common.metrics.CompoundStat
A compound stat providing various metrics based on an internally maintained HdrHistogram. It should be more performant, more precise, and much more flexible regarding concurrent usage compared to either the most commonly used in the Kafka codebase Yammer histograms or the existing Kafka Metrics alternatives like Percentiles.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.kafka.common.metrics.CompoundStat

    org.apache.kafka.common.metrics.CompoundStat.NamedMeasurable
  • Method Summary

    Modifier and Type
    Method
    Description
    newLatencyHistogram(Function<String, org.apache.kafka.common.MetricName> metricNameFactory, long highestTrackableValue)
    Creates a new histogram with the purpose of tracking latency values.
    void
    record(org.apache.kafka.common.metrics.MetricConfig config, double value, long timeMs)
     
    List<org.apache.kafka.common.metrics.CompoundStat.NamedMeasurable>
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • newLatencyHistogram

      public static KafkaMetricHistogram newLatencyHistogram(Function<String, org.apache.kafka.common.MetricName> metricNameFactory, long highestTrackableValue)
      Creates a new histogram with the purpose of tracking latency values. As such, the histogram defaults to a thread-safety mode allowing concurrent reads and writes and 3-digit precision across its range (higher precision significantly increases the memory footprint of the histogram and is rarely needed).
      Parameters:
      metricNameFactory - A factory for creating a MetricName based on a metric name string.
      highestTrackableValue - The maximum trackable value for the histogram, e.g. something with some safety margin above the configured request timeout for request latencies.
      Returns:
      A new KafkaMetricHistogram with the configured properties.
    • stats

      public List<org.apache.kafka.common.metrics.CompoundStat.NamedMeasurable> stats()
      Specified by:
      stats in interface org.apache.kafka.common.metrics.CompoundStat
    • record

      public void record(org.apache.kafka.common.metrics.MetricConfig config, double value, long timeMs)
      Specified by:
      record in interface org.apache.kafka.common.metrics.Stat