Class StreamsMetricsImpl

    • Constructor Detail

      • StreamsMetricsImpl

        public StreamsMetricsImpl​(org.apache.kafka.common.metrics.Metrics metrics,
                                  String clientId,
                                  String builtInMetricsVersion)
    • Method Detail

      • setRocksDBMetricsRecordingTrigger

        public void setRocksDBMetricsRecordingTrigger​(RocksDBMetricsRecordingTrigger rocksDBMetricsRecordingTrigger)
      • addClientLevelImmutableMetric

        public <T> void addClientLevelImmutableMetric​(String name,
                                                      String description,
                                                      org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                      T value)
      • addClientLevelMutableMetric

        public <T> void addClientLevelMutableMetric​(String name,
                                                    String description,
                                                    org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                    org.apache.kafka.common.metrics.Gauge<T> valueProvider)
      • threadLevelSensor

        public final org.apache.kafka.common.metrics.Sensor threadLevelSensor​(String threadId,
                                                                              String sensorName,
                                                                              org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                              org.apache.kafka.common.metrics.Sensor... parents)
      • removeAllClientLevelMetrics

        public final void removeAllClientLevelMetrics()
      • removeAllThreadLevelSensors

        public final void removeAllThreadLevelSensors​(String threadId)
      • taskLevelSensor

        public final org.apache.kafka.common.metrics.Sensor taskLevelSensor​(String threadId,
                                                                            String taskId,
                                                                            String sensorName,
                                                                            org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                            org.apache.kafka.common.metrics.Sensor... parents)
      • removeAllTaskLevelSensors

        public final void removeAllTaskLevelSensors​(String threadId,
                                                    String taskId)
      • nodeLevelSensor

        public org.apache.kafka.common.metrics.Sensor nodeLevelSensor​(String threadId,
                                                                      String taskId,
                                                                      String processorNodeName,
                                                                      String sensorName,
                                                                      org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                      org.apache.kafka.common.metrics.Sensor... parents)
      • removeAllNodeLevelSensors

        public final void removeAllNodeLevelSensors​(String threadId,
                                                    String taskId,
                                                    String processorNodeName)
      • cacheLevelSensor

        public org.apache.kafka.common.metrics.Sensor cacheLevelSensor​(String threadId,
                                                                       String taskName,
                                                                       String storeName,
                                                                       String sensorName,
                                                                       org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                       org.apache.kafka.common.metrics.Sensor... parents)
      • removeAllCacheLevelSensors

        public final void removeAllCacheLevelSensors​(String threadId,
                                                     String taskId,
                                                     String cacheName)
      • storeLevelSensor

        public final org.apache.kafka.common.metrics.Sensor storeLevelSensor​(String threadId,
                                                                             String taskId,
                                                                             String storeName,
                                                                             String sensorName,
                                                                             org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                             org.apache.kafka.common.metrics.Sensor... parents)
      • removeAllStoreLevelSensors

        public final void removeAllStoreLevelSensors​(String threadId,
                                                     String taskId,
                                                     String storeName)
      • recordThroughput

        @Deprecated
        public void recordThroughput​(org.apache.kafka.common.metrics.Sensor sensor,
                                     long value)
        Deprecated.
        Description copied from interface: StreamsMetrics
        Record the throughput value of a sensor.
        Specified by:
        recordThroughput in interface StreamsMetrics
        Parameters:
        sensor - add Sensor whose throughput we are recording
        value - throughput value
      • addLatencyRateTotalSensor

        public org.apache.kafka.common.metrics.Sensor addLatencyRateTotalSensor​(String scopeName,
                                                                                String entityName,
                                                                                String operationName,
                                                                                org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                                String... tags)
        Description copied from interface: StreamsMetrics
        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().
        Specified by:
        addLatencyRateTotalSensor in interface StreamsMetrics
        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:
        StreamsMetrics.addRateTotalSensor(String, String, String, Sensor.RecordingLevel, String...), StreamsMetrics.removeSensor(Sensor), StreamsMetrics.addSensor(String, Sensor.RecordingLevel, Sensor...)
      • addRateTotalSensor

        public org.apache.kafka.common.metrics.Sensor addRateTotalSensor​(String scopeName,
                                                                         String entityName,
                                                                         String operationName,
                                                                         org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                         String... tags)
        Description copied from interface: StreamsMetrics
        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().
        Specified by:
        addRateTotalSensor in interface StreamsMetrics
        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:
        StreamsMetrics.addLatencyRateTotalSensor(String, String, String, Sensor.RecordingLevel, String...), StreamsMetrics.removeSensor(Sensor), StreamsMetrics.addSensor(String, Sensor.RecordingLevel, Sensor...)
      • addLatencyAndThroughputSensor

        @Deprecated
        public org.apache.kafka.common.metrics.Sensor addLatencyAndThroughputSensor​(String scopeName,
                                                                                    String entityName,
                                                                                    String operationName,
                                                                                    org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                                    String... tags)
        Deprecated.
        Description copied from interface: StreamsMetrics
        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.
        Specified by:
        addLatencyAndThroughputSensor in interface StreamsMetrics
        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.
        Throws:
        IllegalArgumentException - if tags is not constructed in key-value pairs
      • addThroughputSensor

        @Deprecated
        public org.apache.kafka.common.metrics.Sensor addThroughputSensor​(String scopeName,
                                                                          String entityName,
                                                                          String operationName,
                                                                          org.apache.kafka.common.metrics.Sensor.RecordingLevel recordingLevel,
                                                                          String... tags)
        Deprecated.
        Description copied from interface: StreamsMetrics
        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 StreamsMetrics.addLatencyAndThroughputSensor(String, String, String, Sensor.RecordingLevel, String...).
        Specified by:
        addThroughputSensor in interface StreamsMetrics
        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.
        Throws:
        IllegalArgumentException - if tags is not constructed in key-value pairs
      • addAvgAndMaxToSensor

        public static void addAvgAndMaxToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                String group,
                                                Map<String,​String> tags,
                                                String operation,
                                                String descriptionOfAvg,
                                                String descriptionOfMax)
      • addMinAndMaxToSensor

        public static void addMinAndMaxToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                String group,
                                                Map<String,​String> tags,
                                                String operation,
                                                String descriptionOfMin,
                                                String descriptionOfMax)
      • addAvgAndMaxLatencyToSensor

        public static void addAvgAndMaxLatencyToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                       String group,
                                                       Map<String,​String> tags,
                                                       String operation)
      • addAvgAndMinAndMaxToSensor

        public static void addAvgAndMinAndMaxToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                      String group,
                                                      Map<String,​String> tags,
                                                      String operation,
                                                      String descriptionOfAvg,
                                                      String descriptionOfMin,
                                                      String descriptionOfMax)
      • addInvocationRateAndCountToSensor

        public static void addInvocationRateAndCountToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                             String group,
                                                             Map<String,​String> tags,
                                                             String operation,
                                                             String descriptionOfRate,
                                                             String descriptionOfCount)
      • addInvocationRateToSensor

        public static void addInvocationRateToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                     String group,
                                                     Map<String,​String> tags,
                                                     String operation,
                                                     String descriptionOfRate)
      • addInvocationRateAndCountToSensor

        public static void addInvocationRateAndCountToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                             String group,
                                                             Map<String,​String> tags,
                                                             String operation)
      • addRateOfSumAndSumMetricsToSensor

        public static void addRateOfSumAndSumMetricsToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                             String group,
                                                             Map<String,​String> tags,
                                                             String operation,
                                                             String descriptionOfRate,
                                                             String descriptionOfTotal)
      • addRateOfSumMetricToSensor

        public static void addRateOfSumMetricToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                      String group,
                                                      Map<String,​String> tags,
                                                      String operation,
                                                      String description)
      • addSumMetricToSensor

        public static void addSumMetricToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                String group,
                                                Map<String,​String> tags,
                                                String operation,
                                                String description)
      • addSumMetricToSensor

        public static void addSumMetricToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                String group,
                                                Map<String,​String> tags,
                                                String operation,
                                                boolean withSuffix,
                                                String description)
      • addValueMetricToSensor

        public static void addValueMetricToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                  String group,
                                                  Map<String,​String> tags,
                                                  String name,
                                                  String description)
      • addAvgAndSumMetricsToSensor

        public static void addAvgAndSumMetricsToSensor​(org.apache.kafka.common.metrics.Sensor sensor,
                                                       String group,
                                                       Map<String,​String> tags,
                                                       String metricNamePrefix,
                                                       String descriptionOfAvg,
                                                       String descriptionOfTotal)
      • maybeMeasureLatency

        public static void maybeMeasureLatency​(Runnable actionToMeasure,
                                               org.apache.kafka.common.utils.Time time,
                                               org.apache.kafka.common.metrics.Sensor sensor)
      • maybeMeasureLatency

        public static <T> T maybeMeasureLatency​(Supplier<T> actionToMeasure,
                                                org.apache.kafka.common.utils.Time time,
                                                org.apache.kafka.common.metrics.Sensor sensor)
      • removeSensor

        public void removeSensor​(org.apache.kafka.common.metrics.Sensor sensor)
        Deletes a sensor and its parents, if any
        Specified by:
        removeSensor in interface StreamsMetrics
        Parameters:
        sensor - sensor to be removed