Interface StreamsMetrics

  • All Known Implementing Classes:
    StreamsMetricsImpl

    @Evolving
    public interface StreamsMetrics
    The Kafka Streams metrics interface for adding metric sensors and collecting metric values.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      org.apache.kafka.common.metrics.Sensor addLatencyAndThroughputSensor​(java.lang.String scopeName, java.lang.String entityName, java.lang.String operationName, org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel, java.lang.String... tags)
      Add a latency and throughput sensor for a specific operation, which will include the following sensors: average latency max latency throughput (num.operations / time unit) Also create a parent sensor with the same metrics that aggregates all entities with the same operation under the same scope if it has not been created.
      org.apache.kafka.common.metrics.Sensor addSensor​(java.lang.String name, org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel)
      Generic method to create a sensor.
      org.apache.kafka.common.metrics.Sensor addSensor​(java.lang.String name, org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel, org.apache.kafka.common.metrics.Sensor... parents)
      Generic method to create a sensor with parent sensors.
      org.apache.kafka.common.metrics.Sensor addThroughputSensor​(java.lang.String scopeName, java.lang.String entityName, java.lang.String operationName, org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel, java.lang.String... tags)
      Add a throughput sensor for a specific operation: throughput (num.operations / time unit) Also create a parent sensor with the same metrics that aggregates all entities with the same operation under the same scope if it has not been created.
      java.util.Map<org.apache.kafka.common.MetricName,​? extends org.apache.kafka.common.Metric> metrics()
      Get read-only handle on global metrics registry.
      void recordLatency​(org.apache.kafka.common.metrics.Sensor sensor, long startNs, long endNs)
      Record the given latency value of the sensor.
      void recordThroughput​(org.apache.kafka.common.metrics.Sensor sensor, long value)
      Record the throughput value of a sensor.
      void removeSensor​(org.apache.kafka.common.metrics.Sensor sensor)
      Remove a sensor.
    • Method Detail

      • metrics

        java.util.Map<org.apache.kafka.common.MetricName,​? extends org.apache.kafka.common.Metric> metrics()
        Get read-only handle on global metrics registry.
        Returns:
        Map of all metrics.
      • addLatencyAndThroughputSensor

        org.apache.kafka.common.metrics.Sensor addLatencyAndThroughputSensor​(java.lang.String scopeName,
                                                                             java.lang.String entityName,
                                                                             java.lang.String operationName,
                                                                             org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                             java.lang.String... tags)
        Add a latency and throughput sensor for a specific operation, which will include the following sensors:
        1. average latency
        2. max latency
        3. throughput (num.operations / time unit)
        Also create a parent sensor with the same metrics that aggregates all entities with the same operation under the same scope if it has not been created.
        Parameters:
        scopeName - name of the scope, could be the type of the state store, etc.
        entityName - name of the entity, could be the name of the state store instance, etc.
        operationName - name of the operation, could be get / put / delete / etc.
        recordingLevel - the recording level (e.g., INFO or DEBUG) for this sensor.
        tags - additional tags of the sensor
        Returns:
        The added sensor.
      • recordLatency

        void recordLatency​(org.apache.kafka.common.metrics.Sensor sensor,
                           long startNs,
                           long endNs)
        Record the given latency value of the sensor. If the passed sensor includes throughput metrics, e.g., when created by the addLatencyAndThroughputSensor(String, String, String, Sensor.RecordingLevel, String...) method, then the throughput metrics will also be recorded from this event.
        Parameters:
        sensor - sensor whose latency we are recording.
        startNs - start of measurement time in nanoseconds.
        endNs - end of measurement time in nanoseconds.
      • addThroughputSensor

        org.apache.kafka.common.metrics.Sensor addThroughputSensor​(java.lang.String scopeName,
                                                                   java.lang.String entityName,
                                                                   java.lang.String operationName,
                                                                   org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                   java.lang.String... tags)
        Add a throughput sensor for a specific operation:
        1. throughput (num.operations / time unit)
        Also create a parent sensor with the same metrics that aggregates all entities with the same operation under the same scope if it has not been created. This sensor is a strict subset of the sensors created by addLatencyAndThroughputSensor(String, String, String, Sensor.RecordingLevel, String...).
        Parameters:
        scopeName - name of the scope, could be the type of the state store, etc.
        entityName - name of the entity, could be the name of the state store instance, etc.
        operationName - name of the operation, could be get / put / delete / etc.
        recordingLevel - the recording level (e.g., INFO or DEBUG) for this sensor.
        tags - additional tags of the sensor
        Returns:
        The added sensor.
      • recordThroughput

        void recordThroughput​(org.apache.kafka.common.metrics.Sensor sensor,
                              long value)
        Record the throughput value of a sensor.
        Parameters:
        sensor - add Sensor whose throughput we are recording
        value - throughput value
      • removeSensor

        void removeSensor​(org.apache.kafka.common.metrics.Sensor sensor)
        Remove a sensor.
        Parameters:
        sensor - sensor to be removed