Package org.apache.kafka.streams
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:- average latency
- max latency
- throughput (num.operations / time unit)
- 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 theaddLatencyAndThroughputSensor(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:- throughput (num.operations / time unit)
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 recordingvalue
- throughput value
-
addSensor
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. Note that for most cases it is advisable to useaddThroughputSensor(String, String, String, Sensor.RecordingLevel, String...)
oraddLatencyAndThroughputSensor(String, String, String, Sensor.RecordingLevel, String...)
to ensure metric name well-formedness and conformity with the rest of the streams code base. However, if the above two methods are not sufficient, this method can also be used.- Parameters:
name
- name of the sensor.recordingLevel
- the recording level (e.g., INFO or DEBUG) for this sensor- Returns:
- The added sensor.
-
addSensor
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. Note that for most cases it is advisable to useaddThroughputSensor(String, String, String, Sensor.RecordingLevel, String...)
oraddLatencyAndThroughputSensor(String, String, String, Sensor.RecordingLevel, String...)
to ensure metric name well-formedness and conformity with the rest of the streams code base. However, if the above two methods are not sufficient, this method can also be used.- Parameters:
name
- name of the sensorrecordingLevel
- the recording level (e.g., INFO or DEBUG) for this sensor- Returns:
- The added sensor.
-
removeSensor
void removeSensor(org.apache.kafka.common.metrics.Sensor sensor)
Remove a sensor.- Parameters:
sensor
- sensor to be removed
-
-