Interface StreamsMetrics


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

      • metrics

        Map<MetricName,​? extends Metric> metrics()
        Get read-only handle on global metrics registry.
        Returns:
        Map of all metrics.
      • addLatencyRateTotalSensor

        Sensor addLatencyRateTotalSensor​(String scopeName,
                                         String entityName,
                                         String operationName,
                                         Sensor.RecordingLevel recordingLevel,
                                         String... tags)
        Add a latency, rate and total sensor for a specific operation, which will include the following metrics:
        1. average latency
        2. max latency
        3. invocation rate (num.operations / seconds)
        4. total invocation count
        Whenever a user records this sensor via Sensor.record(double) etc, it will be counted as one invocation of the operation, and hence the rate / count metrics will be updated accordingly; and the recorded latency value will be used to update the average / max latency as well. Note that you can add more metrics to this sensor after you created it, which can then be updated upon Sensor.record(double) calls. The added sensor and its metrics can be removed with removeSensor().
        Parameters:
        scopeName - name of the scope, which will be used as part of the metric type, e.g.: "stream-[scope]-metrics".
        entityName - name of the entity, which will be used as part of the metric tags, e.g.: "[scope]-id" = "[entity]".
        operationName - name of the operation, which will be used as the name of the metric, e.g.: "[operation]-latency-avg".
        recordingLevel - the recording level (e.g., INFO or DEBUG) for this sensor.
        tags - additional tags of the sensor
        Returns:
        The added sensor.
        See Also:
        addRateTotalSensor(String, String, String, Sensor.RecordingLevel, String...), removeSensor(Sensor), addSensor(String, Sensor.RecordingLevel, Sensor...)
      • addRateTotalSensor

        Sensor addRateTotalSensor​(String scopeName,
                                  String entityName,
                                  String operationName,
                                  Sensor.RecordingLevel recordingLevel,
                                  String... tags)
        Add a rate and a total sensor for a specific operation, which will include the following metrics:
        1. invocation rate (num.operations / time unit)
        2. total invocation count
        Whenever a user records this sensor via Sensor.record(double) etc, it will be counted as one invocation of the operation, and hence the rate / count metrics will be updated accordingly. Note that you can add more metrics to this sensor after you created it, which can then be updated upon Sensor.record(double) calls. The added sensor and its metrics can be removed with removeSensor().
        Parameters:
        scopeName - name of the scope, which will be used as part of the metrics type, e.g.: "stream-[scope]-metrics".
        entityName - name of the entity, which will be used as part of the metric tags, e.g.: "[scope]-id" = "[entity]".
        operationName - name of the operation, which will be used as the name of the metric, e.g.: "[operation]-total".
        recordingLevel - the recording level (e.g., INFO or DEBUG) for this sensor.
        tags - additional tags of the sensor
        Returns:
        The added sensor.
        See Also:
        addLatencyRateTotalSensor(String, String, String, Sensor.RecordingLevel, String...), removeSensor(Sensor), addSensor(String, Sensor.RecordingLevel, Sensor...)
      • addLatencyAndThroughputSensor

        @Deprecated
        Sensor addLatencyAndThroughputSensor​(String scopeName,
                                             String entityName,
                                             String operationName,
                                             Sensor.RecordingLevel recordingLevel,
                                             String... tags)
        Deprecated.
        since 2.5. Use addLatencyRateTotalSensor() instead.
        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.
      • addThroughputSensor

        @Deprecated
        Sensor addThroughputSensor​(String scopeName,
                                   String entityName,
                                   String operationName,
                                   Sensor.RecordingLevel recordingLevel,
                                   String... tags)
        Deprecated.
        since 2.5. Use addRateTotalSensor() instead.
        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

        @Deprecated
        void recordThroughput​(Sensor sensor,
                              long value)
        Deprecated.
        since 2.5. Use Sensor#record() instead.
        Record the throughput value of a sensor.
        Parameters:
        sensor - add Sensor whose throughput we are recording
        value - throughput value
      • removeSensor

        void removeSensor​(Sensor sensor)
        Remove a sensor.
        Parameters:
        sensor - sensor to be removed