-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-8578: Add basic functionality to expose RocksDB metrics #6979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3013214
5f4624f
2f3f161
bacdd7c
1faae95
269ca2a
b4ccf2d
ba1cbbc
e531069
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,9 +23,12 @@ | |
| import org.apache.kafka.common.metrics.Sensor.RecordingLevel; | ||
| import org.apache.kafka.common.metrics.stats.Avg; | ||
| import org.apache.kafka.common.metrics.stats.CumulativeCount; | ||
| import org.apache.kafka.common.metrics.stats.CumulativeSum; | ||
| import org.apache.kafka.common.metrics.stats.Max; | ||
| import org.apache.kafka.common.metrics.stats.Rate; | ||
| import org.apache.kafka.common.metrics.stats.Value; | ||
| import org.apache.kafka.common.metrics.stats.WindowedCount; | ||
| import org.apache.kafka.common.metrics.stats.WindowedSum; | ||
| import org.apache.kafka.streams.StreamsMetrics; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
@@ -54,17 +57,21 @@ public class StreamsMetricsImpl implements StreamsMetrics { | |
|
|
||
| public static final String THREAD_ID_TAG = "client-id"; | ||
| public static final String TASK_ID_TAG = "task-id"; | ||
| public static final String STORE_ID_TAG = "state-id"; | ||
|
|
||
| public static final String ALL_TASKS = "all"; | ||
|
|
||
| public static final String LATENCY_SUFFIX = "-latency"; | ||
| public static final String AVG_SUFFIX = "-avg"; | ||
| public static final String MAX_SUFFIX = "-max"; | ||
| public static final String MIN_SUFFIX = "-min"; | ||
| public static final String RATE_SUFFIX = "-rate"; | ||
| public static final String TOTAL_SUFFIX = "-total"; | ||
| public static final String RATIO_SUFFIX = "-ratio"; | ||
|
|
||
| public static final String THREAD_LEVEL_GROUP = "stream-metrics"; | ||
| public static final String TASK_LEVEL_GROUP = "stream-task-metrics"; | ||
| public static final String STATE_LEVEL_GROUP = "stream-state-metrics"; | ||
|
|
||
| public static final String PROCESSOR_NODE_METRICS_GROUP = "stream-processor-node-metrics"; | ||
| public static final String PROCESSOR_NODE_ID_TAG = "processor-node-id"; | ||
|
|
@@ -123,6 +130,18 @@ public final void removeAllThreadLevelSensors() { | |
| } | ||
| } | ||
|
|
||
| public Map<String, String> taskLevelTagMap(final String taskName) { | ||
| final Map<String, String> tagMap = threadLevelTagMap(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Should we do the same here
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I can follow. We do not have a parameter
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I'm not sure what's going on with It has exactly one usage, which is Maybe we can just get rid of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| tagMap.put(TASK_ID_TAG, taskName); | ||
| return tagMap; | ||
| } | ||
|
|
||
| public Map<String, String> storeLevelTagMap(final String taskName, final String storeType, final String storeName) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: line to long (break each parameter in it's own line)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The line is exactly 120 characters long as allowed by the coding guidelines. ;-)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just add https://checkstyle.sourceforge.io/config_sizes.html#LineLength so we never have to have this discussion again? :) |
||
| final Map<String, String> tagMap = taskLevelTagMap(taskName); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above |
||
| tagMap.put(storeType + "-" + STORE_ID_TAG, storeName); | ||
| return tagMap; | ||
| } | ||
|
|
||
| public final Sensor taskLevelSensor(final String taskName, | ||
| final String sensorName, | ||
| final RecordingLevel recordingLevel, | ||
|
|
@@ -237,9 +256,7 @@ public final Sensor storeLevelSensor(final String taskName, | |
| if (!storeLevelSensors.containsKey(key)) { | ||
| storeLevelSensors.put(key, new LinkedList<>()); | ||
| } | ||
|
|
||
| final String fullSensorName = key + SENSOR_NAME_DELIMITER + sensorName; | ||
|
|
||
| final Sensor sensor = metrics.sensor(fullSensorName, recordingLevel, parents); | ||
|
|
||
| storeLevelSensors.get(key).push(fullSensorName); | ||
|
|
@@ -454,12 +471,62 @@ public static void addInvocationRateAndCount(final Sensor sensor, | |
| final String group, | ||
| final Map<String, String> tags, | ||
| final String operation) { | ||
| addInvocationRateAndCount(sensor, | ||
| group, | ||
| tags, | ||
| operation, | ||
| "The total number of " + operation, | ||
| "The average per-second number of " + operation); | ||
| addInvocationRateAndCount( | ||
| sensor, | ||
| group, | ||
| tags, | ||
| operation, | ||
| "The total number of " + operation, | ||
| "The average per-second number of " + operation | ||
| ); | ||
| } | ||
|
|
||
| public static void addRateOfSumAndSumMetricsToSensor(final Sensor sensor, | ||
| final String group, | ||
| final Map<String, String> tags, | ||
| final String operation, | ||
| final String descriptionOfRate, | ||
| final String descriptionOfTotal) { | ||
| addRateOfSumMetricToSensor(sensor, group, tags, operation, descriptionOfRate); | ||
| addSumMetricToSensor(sensor, group, tags, operation, descriptionOfTotal); | ||
| } | ||
|
|
||
| public static void addRateOfSumMetricToSensor(final Sensor sensor, | ||
| final String group, | ||
| final Map<String, String> tags, | ||
| final String operation, | ||
| final String description) { | ||
| sensor.add(new MetricName(operation + RATE_SUFFIX, group, description, tags), | ||
| new Rate(TimeUnit.SECONDS, new WindowedSum())); | ||
| } | ||
|
|
||
| public static void addSumMetricToSensor(final Sensor sensor, | ||
| final String group, | ||
| final Map<String, String> tags, | ||
| final String operation, | ||
| final String description) { | ||
| sensor.add(new MetricName(operation + TOTAL_SUFFIX, group, description, tags), new CumulativeSum()); | ||
| } | ||
|
|
||
| public static void addValueMetricToSensor(final Sensor sensor, | ||
| final String group, | ||
| final Map<String, String> tags, | ||
| final String name, | ||
| final String description) { | ||
| sensor.add(new MetricName(name, group, description, tags), new Value()); | ||
| } | ||
|
|
||
| public static void addAvgAndSumMetricsToSensor(final Sensor sensor, | ||
| final String group, | ||
| final Map<String, String> tags, | ||
| final String metricNamePrefix, | ||
| final String descriptionOfAvg, | ||
| final String descriptionOfTotal) { | ||
| sensor.add(new MetricName(metricNamePrefix + AVG_SUFFIX, group, descriptionOfAvg, tags), new Avg()); | ||
| sensor.add( | ||
| new MetricName(metricNamePrefix + TOTAL_SUFFIX, group, descriptionOfTotal, tags), | ||
| new CumulativeSum() | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be called
store-idthen?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to be consistent with existing state store-level ids.