duongkame commented on code in PR #5907:
URL: https://github.com/apache/ozone/pull/5907#discussion_r1442153439


##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/BlockOutputStreamEntryPool.java:
##########
@@ -368,7 +369,10 @@ void hsyncKey(long offset) throws IOException {
       if (keyArgs.getIsMultipartKey()) {
         throw new IOException("Hsync is unsupported for multipart keys.");
       } else {
+        long start = Time.monotonicNowNanos();

Review Comment:
   We can add the following to `org.apache.hadoop.util.MetricUtil`.
   ```
   public final class MetricUtil {
   ....
     public static <E extends IOException> void captureLatencyNs(Consumer<Long> 
latencySetter, CheckedRunnable<E> block) throws E {
       long start = Time.monotonicNowNanos();
       try {
         block.run();
       } finally {
         latencySetter.accept(Time.monotonicNowNanos() - start);
       }
     }
   ...
   }
   ```
   
   And use it here
   ```
   MetricUtil.captureLatencyNs(clientMetrics::addDataNodeHsyncLatency, () -> 
out1.hsync());
   ```



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