You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by GitBox <gi...@apache.org> on 2022/08/09 08:51:14 UTC

[GitHub] [incubator-uniffle] zuston opened a new pull request, #150: Introduce more grpc server metrics

zuston opened a new pull request, #150:
URL: https://github.com/apache/incubator-uniffle/pull/150

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://github.com/Tencent/Firestorm/blob/master/CONTRIBUTING.md
     2. Ensure you have added or run the appropriate tests for your PR
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]XXXX Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
   -->
   
   ### What changes were proposed in this pull request?
   Introduce more grpc server metrics
   1. grpc_server_executor_active_threads
   2. grpc_server_executor_blocking_queue_size
   3. grpc_server_connection_size
   
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     5. If you fix some SQL features, you can provide some references of other DBMSes.
     6. If there is design documentation, please add the link.
     7. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   Now if the executors size is not enough for handling requests, there is no way to find this problem. And the connection number is need to use the linux command of `nestat` to find. 
   
   So this PR is to introduce these metrics.
   
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   Unit Tests
   
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   


-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r947388715


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -25,6 +25,13 @@
 import io.prometheus.client.Gauge;
 
 public abstract class GRPCMetrics {
+  // Grpc server internal executor metrics
+  public static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG = "grpcServerExecutorActiveThreads";

Review Comment:
   GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG -> GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_KEY ? 
   
   This name wont be as the metric name exposed to rest api result, just be as the gaugeMap key



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi merged pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
jerqi merged PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150


-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] codecov-commenter commented on pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#issuecomment-1214988232

   # [Codecov](https://codecov.io/gh/apache/incubator-uniffle/pull/150?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#150](https://codecov.io/gh/apache/incubator-uniffle/pull/150?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (68730cd) into [master](https://codecov.io/gh/apache/incubator-uniffle/commit/04cbdbb6eec98cdd02fcc770e0cf1298db281c4f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (04cbdbb) will **increase** coverage by `0.18%`.
   > The diff coverage is `67.50%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #150      +/-   ##
   ============================================
   + Coverage     57.20%   57.38%   +0.18%     
   - Complexity     1200     1206       +6     
   ============================================
     Files           150      151       +1     
     Lines          8185     8223      +38     
     Branches        773      774       +1     
   ============================================
   + Hits           4682     4719      +37     
   + Misses         3257     3255       -2     
   - Partials        246      249       +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-uniffle/pull/150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...le/common/rpc/MonitoringServerTransportFilter.java](https://codecov.io/gh/apache/incubator-uniffle/pull/150/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL2NvbW1vbi9ycGMvTW9uaXRvcmluZ1NlcnZlclRyYW5zcG9ydEZpbHRlci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...java/org/apache/uniffle/common/rpc/GrpcServer.java](https://codecov.io/gh/apache/incubator-uniffle/pull/150/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL2NvbW1vbi9ycGMvR3JwY1NlcnZlci5qYXZh) | `28.07% <84.21%> (+28.07%)` | :arrow_up: |
   | [...org/apache/uniffle/common/metrics/GRPCMetrics.java](https://codecov.io/gh/apache/incubator-uniffle/pull/150/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL2NvbW1vbi9tZXRyaWNzL0dSUENNZXRyaWNzLmphdmE=) | `46.51% <84.61%> (+46.51%)` | :arrow_up: |
   | [...e/uniffle/server/storage/SingleStorageManager.java](https://codecov.io/gh/apache/incubator-uniffle/pull/150/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL3NlcnZlci9zdG9yYWdlL1NpbmdsZVN0b3JhZ2VNYW5hZ2VyLmphdmE=) | `67.21% <0.00%> (+1.63%)` | :arrow_up: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston closed pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston closed pull request #150: Introduce more grpc server metrics
URL: https://github.com/apache/incubator-uniffle/pull/150


-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r946577236


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -38,11 +45,36 @@ public abstract class GRPCMetrics {
   public void register(CollectorRegistry collectorRegistry) {
     if (!isRegister) {
       metricsManager = new MetricsManager(collectorRegistry);
+      registerGeneralMetrics();
       registerMetrics();
       isRegister = true;
     }
   }
 
+  private void registerGeneralMetrics() {

Review Comment:
   These metrics are sharable for ShuffleServerGrpcMetrics and CoordinatorGrpcMetrics. I think there is no need to init twice time.



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#issuecomment-1214955037

   If u have time, could u help check this improvement?  @jerqi 


-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r947759789


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -25,6 +25,13 @@
 import io.prometheus.client.Gauge;
 
 public abstract class GRPCMetrics {
+  // Grpc server internal executor metrics
+  public static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG = "grpcServerExecutorActiveThreads";

Review Comment:
   done



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
jerqi commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r946547996


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -38,11 +45,36 @@ public abstract class GRPCMetrics {
   public void register(CollectorRegistry collectorRegistry) {
     if (!isRegister) {
       metricsManager = new MetricsManager(collectorRegistry);
+      registerGeneralMetrics();
       registerMetrics();
       isRegister = true;
     }
   }
 
+  private void registerGeneralMetrics() {

Review Comment:
   Could we put these metrics to the method `registerMetrics`?



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
jerqi commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r947381091


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -25,6 +25,13 @@
 import io.prometheus.client.Gauge;
 
 public abstract class GRPCMetrics {
+  // Grpc server internal executor metrics
+  public static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG = "grpcServerExecutorActiveThreads";

Review Comment:
   `TAG` is too general, I feel it's a little inappropriate, could we give it a better name?



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
jerqi commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r946649348


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -25,6 +25,13 @@
 import io.prometheus.client.Gauge;
 
 public abstract class GRPCMetrics {
+  // Grpc server internal executor metrics
+  public static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG = "grpcServerExecutorActiveThreads";

Review Comment:
   Why does our name contain `TAG`?



##########
common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java:
##########
@@ -76,6 +81,41 @@ public GrpcServer(RssBaseConf conf, BindableService service, GRPCMetrics grpcMet
     }
   }
 
+  public static class GrpcThreadPoolExecutor extends ThreadPoolExecutor {
+    private final GRPCMetrics grpcMetrics;
+    private final AtomicLong activeThreadSize = new AtomicLong(0L);
+
+    public GrpcThreadPoolExecutor(
+        int corePoolSize,
+        int maximumPoolSize,
+        long keepAliveTime,
+        TimeUnit unit,
+        BlockingQueue<Runnable> workQueue,
+        ThreadFactory threadFactory,
+        GRPCMetrics grpcMetrics) {
+      super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
+      this.grpcMetrics = grpcMetrics;
+    }
+
+    @Override
+    protected void beforeExecute(Thread t, Runnable r) {
+      grpcMetrics.setGauge(GRPCMetrics.GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG,
+          activeThreadSize.incrementAndGet());
+      grpcMetrics.setGauge(GRPCMetrics.GRPC_SERVER_EXECUTOR_BLOCKING_QUEUE_SIZE_TAG,
+          getQueue().size());
+      super.beforeExecute(t, r);
+    }
+
+    @Override
+    protected void afterExecute(Runnable r, Throwable t) {

Review Comment:
   Will the method be called if an exception occurs.



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#issuecomment-1217889308

   Thanks for your patient review. @jerqi 


-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
jerqi commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r946273673


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -25,6 +25,13 @@
 import io.prometheus.client.Gauge;
 
 public abstract class GRPCMetrics {
+  // Grpc server internal executor metrics
+  public static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG = "grpcServerExecutorActiveThreads";
+  public static final String GRPC_SERVER_EXECUTOR_BLOCKING_QUEUE_SIZE_TAG = "grpcServerExecutorBlockingQueueSize";
+  private static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS = "grpc_server_executor_active_threads";
+  private static final String GRPC_SERVER_EXECUTOR_BLOCKING_QUEUE_SIZE = "grpc_server_executor_blocking_queue_size";
+  public static final String GRCP_SERVER_CONNECTION_SIZE_TAG = "grpc_server_connection_size";
+  private static final String GRCP_SERVER_CONNECTION_SOCKETS_SIZE = "grpc_server_connection_size";

Review Comment:
   Why `GRCP_SERVER_CONNECTION_SIZE_TAG` and `GRCP_SERVER_CONNECTION_SOCKETS_SIZE` have the same metrics name?



##########
common/src/main/java/org/apache/uniffle/common/rpc/MonitoringServerTransportFilter.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.uniffle.common.rpc;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import io.grpc.Attributes;
+import io.grpc.ServerTransportFilter;
+
+import org.apache.uniffle.common.metrics.GRPCMetrics;
+
+import static org.apache.uniffle.common.metrics.GRPCMetrics.GRCP_SERVER_CONNECTION_SIZE_TAG;
+
+public class MonitoringServerTransportFilter extends ServerTransportFilter {
+  private final AtomicLong connectionSize = new AtomicLong(0);
+  private final GRPCMetrics grpcMetrics;
+
+  public MonitoringServerTransportFilter(GRPCMetrics grpcMetrics) {
+    this.grpcMetrics = grpcMetrics;
+  }
+
+  public Attributes transportReady(Attributes transportAttrs) {
+    grpcMetrics.setGauge(GRCP_SERVER_CONNECTION_SIZE_TAG, connectionSize.incrementAndGet());
+    return super.transportReady(transportAttrs);
+  }
+
+  public void transportTerminated(Attributes transportAttrs) {
+    grpcMetrics.setGauge(GRCP_SERVER_CONNECTION_SIZE_TAG, connectionSize.decrementAndGet());

Review Comment:
   Should we call `super.transportTerminated`?



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
jerqi commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r947527440


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -25,6 +25,13 @@
 import io.prometheus.client.Gauge;
 
 public abstract class GRPCMetrics {
+  // Grpc server internal executor metrics
+  public static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG = "grpcServerExecutorActiveThreads";

Review Comment:
   OK.



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r946538474


##########
common/src/main/java/org/apache/uniffle/common/rpc/MonitoringServerTransportFilter.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.uniffle.common.rpc;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import io.grpc.Attributes;
+import io.grpc.ServerTransportFilter;
+
+import org.apache.uniffle.common.metrics.GRPCMetrics;
+
+import static org.apache.uniffle.common.metrics.GRPCMetrics.GRCP_SERVER_CONNECTION_SIZE_TAG;
+
+public class MonitoringServerTransportFilter extends ServerTransportFilter {
+  private final AtomicLong connectionSize = new AtomicLong(0);
+  private final GRPCMetrics grpcMetrics;
+
+  public MonitoringServerTransportFilter(GRPCMetrics grpcMetrics) {
+    this.grpcMetrics = grpcMetrics;
+  }
+
+  public Attributes transportReady(Attributes transportAttrs) {
+    grpcMetrics.setGauge(GRCP_SERVER_CONNECTION_SIZE_TAG, connectionSize.incrementAndGet());
+    return super.transportReady(transportAttrs);
+  }
+
+  public void transportTerminated(Attributes transportAttrs) {
+    grpcMetrics.setGauge(GRCP_SERVER_CONNECTION_SIZE_TAG, connectionSize.decrementAndGet());

Review Comment:
   Yes, it should. Updated.



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r946814947


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -25,6 +25,13 @@
 import io.prometheus.client.Gauge;
 
 public abstract class GRPCMetrics {
+  // Grpc server internal executor metrics
+  public static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG = "grpcServerExecutorActiveThreads";

Review Comment:
   `TAG` is an identifier of metric, like the `REGISTER_SHUFFLE_METHOD` in `ShuffleServerGrpcMetrics`.
   
   In order to distinguish the name of `gaugeMap` and the name of the metricsManager's `gauge`, the TAG reservation is necessary



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r946804885


##########
common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java:
##########
@@ -76,6 +81,41 @@ public GrpcServer(RssBaseConf conf, BindableService service, GRPCMetrics grpcMet
     }
   }
 
+  public static class GrpcThreadPoolExecutor extends ThreadPoolExecutor {
+    private final GRPCMetrics grpcMetrics;
+    private final AtomicLong activeThreadSize = new AtomicLong(0L);
+
+    public GrpcThreadPoolExecutor(
+        int corePoolSize,
+        int maximumPoolSize,
+        long keepAliveTime,
+        TimeUnit unit,
+        BlockingQueue<Runnable> workQueue,
+        ThreadFactory threadFactory,
+        GRPCMetrics grpcMetrics) {
+      super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
+      this.grpcMetrics = grpcMetrics;
+    }
+
+    @Override
+    protected void beforeExecute(Thread t, Runnable r) {
+      grpcMetrics.setGauge(GRPCMetrics.GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG,
+          activeThreadSize.incrementAndGet());
+      grpcMetrics.setGauge(GRPCMetrics.GRPC_SERVER_EXECUTOR_BLOCKING_QUEUE_SIZE_TAG,
+          getQueue().size());
+      super.beforeExecute(t, r);
+    }
+
+    @Override
+    protected void afterExecute(Runnable r, Throwable t) {

Review Comment:
   Yes, it will.  And the `Throwable t` will not null when exception is thrown



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#issuecomment-1210122681

   cc @jerqi 


-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
jerqi commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r946645114


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -38,11 +45,36 @@ public abstract class GRPCMetrics {
   public void register(CollectorRegistry collectorRegistry) {
     if (!isRegister) {
       metricsManager = new MetricsManager(collectorRegistry);
+      registerGeneralMetrics();
       registerMetrics();
       isRegister = true;
     }
   }
 
+  private void registerGeneralMetrics() {

Review Comment:
   OK.



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org


[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #150: Introduce more grpc server metrics

Posted by GitBox <gi...@apache.org>.
zuston commented on code in PR #150:
URL: https://github.com/apache/incubator-uniffle/pull/150#discussion_r946372521


##########
common/src/main/java/org/apache/uniffle/common/metrics/GRPCMetrics.java:
##########
@@ -25,6 +25,13 @@
 import io.prometheus.client.Gauge;
 
 public abstract class GRPCMetrics {
+  // Grpc server internal executor metrics
+  public static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_TAG = "grpcServerExecutorActiveThreads";
+  public static final String GRPC_SERVER_EXECUTOR_BLOCKING_QUEUE_SIZE_TAG = "grpcServerExecutorBlockingQueueSize";
+  private static final String GRPC_SERVER_EXECUTOR_ACTIVE_THREADS = "grpc_server_executor_active_threads";
+  private static final String GRPC_SERVER_EXECUTOR_BLOCKING_QUEUE_SIZE = "grpc_server_executor_blocking_queue_size";
+  public static final String GRCP_SERVER_CONNECTION_SIZE_TAG = "grpc_server_connection_size";
+  private static final String GRCP_SERVER_CONNECTION_SOCKETS_SIZE = "grpc_server_connection_size";

Review Comment:
   My mistake. It should be like `public static final String GRCP_SERVER_CONNECTION_SIZE_TAG = "grpcServerConnectionSize"`.
   
   And `GRCP_SERVER_CONNECTION_SOCKETS_SIZE` rename to `GRCP_SERVER_CONNECTION_SIZE` to keep consistent.



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org