hangc0276 commented on code in PR #3546:
URL: https://github.com/apache/bookkeeper/pull/3546#discussion_r997659033


##########
bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java:
##########
@@ -434,43 +430,46 @@ protected OrderedExecutor(String baseName, int 
numThreads, ThreadFactory threadF
                 throw new RuntimeException("Couldn't start thread " + i, e);
             }
 
-            // Register gauges
-            statsLogger.scopeLabel("thread", String.valueOf(idx))
-                    .registerGauge(String.format("%s-queue", name), new 
Gauge<Number>() {
-                @Override
-                public Number getDefaultValue() {
-                    return 0;
-                }
-
-                @Override
-                public Number getSample() {
-                    return thread.getQueue().size();
-                }
-            });
-            statsLogger.scopeLabel("thread", String.valueOf(idx))
-                    .registerGauge(String.format("%s-completed-tasks", name), 
new Gauge<Number>() {
-                @Override
-                public Number getDefaultValue() {
-                    return 0;
-                }
-
-                @Override
-                public Number getSample() {
-                    return thread.getCompletedTaskCount();
-                }
-            });
-            statsLogger.scopeLabel("thread", String.valueOf(idx))
-                    .registerGauge(String.format("%s-total-tasks", name), new 
Gauge<Number>() {
-                @Override
-                public Number getDefaultValue() {
-                    return 0;
-                }
-
-                @Override
-                public Number getSample() {
-                    return thread.getTaskCount();
-                }
-            });
+            if (thread instanceof ThreadPoolExecutor) {

Review Comment:
   The thread created by `createSingleThreadExecutor` is not a subclass of 
`ThreadPoolExecutor`, which means we will lose the following thread metrics.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to