YuanbenWang commented on code in PR #5479:
URL: https://github.com/apache/ozone/pull/5479#discussion_r1390871149


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/ProtocolMessageMetrics.java:
##########
@@ -40,32 +44,59 @@ public class ProtocolMessageMetrics<KEY> implements 
MetricsSource {
 
   private final String description;
 
+  private final MetricsRegistry registry;
+
+  private final boolean quantileEnable;
+
   private final Map<KEY, AtomicLong> counters =
       new ConcurrentHashMap<>();
 
   private final Map<KEY, AtomicLong> elapsedTimes =
       new ConcurrentHashMap<>();
 
+  private final Map<KEY, MutableQuantiles[]> quantiles =
+      new ConcurrentHashMap<>();
+
   private final AtomicInteger concurrency = new AtomicInteger(0);
 
   public static <KEY> ProtocolMessageMetrics<KEY> create(String name,
-      String description, KEY[] types) {
-    return new ProtocolMessageMetrics<KEY>(name, description, types);
+      String description, KEY[] types, ConfigurationSource conf) {
+    return new ProtocolMessageMetrics<KEY>(name, description, types, conf);
   }
 
   public ProtocolMessageMetrics(String name, String description,
-      KEY[] values) {
+      KEY[] values, ConfigurationSource conf) {
     this.name = name;
     this.description = description;
+    registry = new MetricsRegistry(name + "MessageMetrics");
+    int[] intervals = conf.getInts(
+        OzoneConfigKeys.OZONE_PROTOCOL_MESSAGE_METRICS_PERCENTILES_INTERVALS);
+    quantileEnable = (intervals.length > 0);
     for (KEY value : values) {
       counters.put(value, new AtomicLong(0));
       elapsedTimes.put(value, new AtomicLong(0));
+      if (quantileEnable) {
+        MutableQuantiles[] mutableQuantiles =
+            new MutableQuantiles[intervals.length];
+        quantiles.put(value, mutableQuantiles);
+        for (int i = 0; i < intervals.length; i++) {
+          mutableQuantiles[i] = registry.newQuantiles(
+              value.toString() + "RpcTime" + intervals[i] + "s",
+              value.toString() + "rpc time in milli second",
+              "ops", "latency", intervals[i]);

Review Comment:
   Now the name of the Metric will be like 
“InfoVolumeRpcTime127s90thPercentileLatency” and the unit of time is including 
in it as "s". It will be appreciated if you could tell me how to let it more 
suitable. How about "InfoVolumeRpcTime127latencySeconds90thPercentileLatency"?  
@xichen01 



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to