You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/12/01 02:08:06 UTC

[GitHub] [kafka] mjsax commented on a change in pull request #9614: KAFKA-10500: Add failed-stream-threads metric for adding + removing stream threads

mjsax commented on a change in pull request #9614:
URL: https://github.com/apache/kafka/pull/9614#discussion_r533020449



##########
File path: streams/src/main/java/org/apache/kafka/streams/processor/internals/metrics/StreamsMetricsImpl.java
##########
@@ -214,6 +215,20 @@ public RocksDBMetricsRecordingTrigger rocksDBMetricsRecordingTrigger() {
         }
     }
 
+    public final Sensor clientLevelSensor(final String sensorName,
+                                          final RecordingLevel recordingLevel,
+                                          final Sensor... parents) {
+        synchronized (clientLevelSensors) {
+            final String fullSensorName = CLIENT_LEVEL_GROUP + SENSOR_NAME_DELIMITER + sensorName;
+            final Sensor sensor = metrics.getSensor(fullSensorName);

Review comment:
       Should we rewrite this the same way `threadLevelSensor` is written (ie, using `orElseGet`) for consistency?

##########
File path: streams/src/test/java/org/apache/kafka/streams/processor/internals/metrics/StreamsMetricsImplTest.java
##########
@@ -629,16 +657,18 @@ private void setupRemoveSensorsTest(final Metrics metrics,
     }
 
     @Test
-    public void shouldRemoveClientLevelMetrics() {
+    public void shouldRemoveClientLevelMetricsAndSensors() {
         final Metrics metrics = niceMock(Metrics.class);
         final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, VERSION, time);
-        addSensorsOnAllLevels(metrics, streamsMetrics);
+        final Capture<String> sensorKeys = addSensorsOnAllLevels(metrics, streamsMetrics);
         resetToDefault(metrics);
-        expect(metrics.removeMetric(metricName1)).andStubReturn(null);
-        expect(metrics.removeMetric(metricName2)).andStubReturn(null);
-        replay(metrics);
 
-        streamsMetrics.removeAllClientLevelMetrics();
+        metrics.removeSensor(sensorKeys.getValues().get(0));
+        metrics.removeSensor(sensorKeys.getValues().get(1));
+        expect(metrics.removeMetric(metricName1)).andReturn(mock(KafkaMetric.class));
+        expect(metrics.removeMetric(metricName2)).andReturn(mock(KafkaMetric.class));

Review comment:
       Why did we change this from `andStubReturn(null)` to `andReturn(mock(KafkaMetric.class))`?

##########
File path: streams/src/main/java/org/apache/kafka/streams/internals/metrics/ClientMetrics.java
##########
@@ -125,4 +131,16 @@ public static void addNumAliveStreamThreadMetric(final StreamsMetricsImpl stream
             stateProvider
         );
     }
+    public static Sensor failedStreamThreadSensor(final StreamsMetricsImpl streamsMetrics) {

Review comment:
       nit: missing empty line




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org