This is an automated email from the ASF dual-hosted git repository. ayushsaxena pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push: new 742e07d9c39 HADOOP-18710. Add RPC metrics for response time (#5545). Contributed by liuguanghua. 742e07d9c39 is described below commit 742e07d9c39eb19dd1bc4fe132c47c82ee7a9f3b Author: LiuGuH <444506...@qq.com> AuthorDate: Sat Apr 22 03:36:08 2023 +0800 HADOOP-18710. Add RPC metrics for response time (#5545). Contributed by liuguanghua. Reviewed-by: Inigo Goiri <inigo...@apache.org> Signed-off-by: Ayush Saxena <ayushsax...@apache.org> --- .../src/main/java/org/apache/hadoop/ipc/Server.java | 3 +++ .../java/org/apache/hadoop/ipc/metrics/RpcMetrics.java | 17 +++++++++++++++++ .../src/test/java/org/apache/hadoop/ipc/TestRPC.java | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java index 9851f9b09fb..e9a605a0043 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java @@ -627,8 +627,11 @@ public abstract class Server { details.get(Timing.PROCESSING, rpcMetrics.getMetricsTimeUnit()); long waitTime = details.get(Timing.LOCKWAIT, rpcMetrics.getMetricsTimeUnit()); + long responseTime = + details.get(Timing.RESPONSE, rpcMetrics.getMetricsTimeUnit()); rpcMetrics.addRpcLockWaitTime(waitTime); rpcMetrics.addRpcProcessingTime(processingTime); + rpcMetrics.addRpcResponseTime(responseTime); // don't include lock wait for detailed metrics. processingTime -= waitTime; String name = call.getDetailedMetricsName(); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java index 282eca3cf83..c18562441fc 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java @@ -75,6 +75,8 @@ public class RpcMetrics { new MutableQuantiles[intervals.length]; rpcProcessingTimeQuantiles = new MutableQuantiles[intervals.length]; + rpcResponseTimeQuantiles = + new MutableQuantiles[intervals.length]; deferredRpcProcessingTimeQuantiles = new MutableQuantiles[intervals.length]; for (int i = 0; i < intervals.length; i++) { @@ -90,6 +92,10 @@ public class RpcMetrics { "rpcProcessingTime" + interval + "s", "rpc processing time in " + metricsTimeUnit, "ops", "latency", interval); + rpcResponseTimeQuantiles[i] = registry.newQuantiles( + "rpcResponseTime" + interval + "s", + "rpc response time in " + metricsTimeUnit, "ops", + "latency", interval); deferredRpcProcessingTimeQuantiles[i] = registry.newQuantiles( "deferredRpcProcessingTime" + interval + "s", "deferred rpc processing time in " + metricsTimeUnit, "ops", @@ -114,6 +120,8 @@ public class RpcMetrics { MutableQuantiles[] rpcLockWaitTimeQuantiles; @Metric("Processing time") MutableRate rpcProcessingTime; MutableQuantiles[] rpcProcessingTimeQuantiles; + @Metric("Response time") MutableRate rpcResponseTime; + MutableQuantiles[] rpcResponseTimeQuantiles; @Metric("Deferred Processing time") MutableRate deferredRpcProcessingTime; MutableQuantiles[] deferredRpcProcessingTimeQuantiles; @Metric("Number of authentication failures") @@ -282,6 +290,15 @@ public class RpcMetrics { } } + public void addRpcResponseTime(long responseTime) { + rpcResponseTime.add(responseTime); + if (rpcQuantileEnable) { + for (MutableQuantiles q : rpcResponseTimeQuantiles) { + q.add(responseTime); + } + } + } + public void addDeferredRpcProcessingTime(long processingTime) { deferredRpcProcessingTime.add(processingTime); if (rpcQuantileEnable) { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java index 9126316fca6..bbc241a420e 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java @@ -1336,12 +1336,16 @@ public class TestRPC extends TestRpcBase { 3000, getLongCounter("RpcProcessingTimeNumOps", rpcMetrics)); assertEquals("Expected correct rpc lock wait count", 3000, getLongCounter("RpcLockWaitTimeNumOps", rpcMetrics)); + assertEquals("Expected correct rpc response count", + 3000, getLongCounter("RpcResponseTimeNumOps", rpcMetrics)); assertEquals("Expected zero rpc lock wait time", 0, getDoubleGauge("RpcLockWaitTimeAvgTime", rpcMetrics), 0.001); MetricsAsserts.assertQuantileGauges("RpcQueueTime" + interval + "s", rpcMetrics); MetricsAsserts.assertQuantileGauges("RpcProcessingTime" + interval + "s", rpcMetrics); + MetricsAsserts.assertQuantileGauges("RpcResponseTime" + interval + "s", + rpcMetrics); String actualUserVsCon = MetricsAsserts .getStringMetric("NumOpenConnectionsPerUser", rpcMetrics); String proxyUser = --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org