You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/05/19 00:49:58 UTC

[GitHub] [druid] wjhypo commented on a change in pull request #11113: Add more metrics for Jetty server thread pool usage

wjhypo commented on a change in pull request #11113:
URL: https://github.com/apache/druid/pull/11113#discussion_r634841505



##########
File path: server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
##########
@@ -499,6 +503,23 @@ public boolean doMonitor(ServiceEmitter emitter)
       final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder();
       MonitorUtils.addDimensionsToBuilder(builder, dimensions);
       emitter.emit(builder.build("jetty/numOpenConnections", ACTIVE_CONNECTIONS.get()));
+      ThreadPool jettyServerThreadPool = JETTY_SERVER_THREAD_POOL.get();
+      emitter.emit(builder.build("jetty/threadPoolNumTotalThreads", jettyServerThreadPool.getThreads()));
+      emitter.emit(builder.build("jetty/threadPoolNumIdleThreads", jettyServerThreadPool.getIdleThreads()));
+      emitter.emit(builder.build("jetty/threadPoolIsLowOnThreads", jettyServerThreadPool.isLowOnThreads() ? 1 : 0));
+      if (jettyServerThreadPool instanceof ThreadPool.SizedThreadPool) {

Review comment:
       Thanks! 1) The min and max threads are just for operation convenience, their value don't change but it's very useful to plot them in the same graph as busy busy threads, for example, to get an idea on the usage, after all, it's not convenient to check druid runtime.properties each time to get the max and min value. Uses don't need them can just not ignore these two metrics. 2) I have simplified the logic to just use QueuedThreadPool to get rid of all the unnecessary checks.

##########
File path: docs/design/extensions-contrib/dropwizard.md
##########
@@ -629,6 +629,38 @@ Latest default metrics mapping can be found [here] (https://github.com/apache/dr
       "priority"
     ],
     "type": "gauge"
+  },
+  "jetty/numOpenConnections": {
+    "dimensions": [],
+    "type": "gauge"
+  },
+  "jetty/threadPoolNumTotalThreads": {

Review comment:
       Thanks! Addressed.

##########
File path: server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
##########
@@ -101,6 +103,7 @@
   private static final Logger log = new Logger(JettyServerModule.class);
 
   private static final AtomicInteger ACTIVE_CONNECTIONS = new AtomicInteger();
+  private static final AtomicReference<ThreadPool> JETTY_SERVER_THREAD_POOL = new AtomicReference<>(null);

Review comment:
       Thanks! Addressed.

##########
File path: server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
##########
@@ -499,6 +503,23 @@ public boolean doMonitor(ServiceEmitter emitter)
       final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder();
       MonitorUtils.addDimensionsToBuilder(builder, dimensions);
       emitter.emit(builder.build("jetty/numOpenConnections", ACTIVE_CONNECTIONS.get()));
+      ThreadPool jettyServerThreadPool = JETTY_SERVER_THREAD_POOL.get();
+      emitter.emit(builder.build("jetty/threadPoolNumTotalThreads", jettyServerThreadPool.getThreads()));
+      emitter.emit(builder.build("jetty/threadPoolNumIdleThreads", jettyServerThreadPool.getIdleThreads()));
+      emitter.emit(builder.build("jetty/threadPoolIsLowOnThreads", jettyServerThreadPool.isLowOnThreads() ? 1 : 0));
+      if (jettyServerThreadPool instanceof ThreadPool.SizedThreadPool) {
+        emitter.emit(builder.build("jetty/threadPoolMinThreads",
+                                   ((ThreadPool.SizedThreadPool) jettyServerThreadPool).getMinThreads()));
+        emitter.emit(builder.build("jetty/threadPoolMaxThreads",
+                                   ((ThreadPool.SizedThreadPool) jettyServerThreadPool).getMaxThreads()));
+      }
+      if (jettyServerThreadPool instanceof QueuedThreadPool) {

Review comment:
       Thanks! Addressed.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org