taklwu commented on code in PR #1385:
URL: https://github.com/apache/ratis/pull/1385#discussion_r2989502961


##########
ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java:
##########
@@ -48,13 +50,21 @@ public final class TraceUtils {
 
   private static final Logger LOG = LoggerFactory.getLogger(TraceUtils.class);
 
+  private static final RaftProperties PROPERTIES = new RaftProperties();

Review Comment:
   got it, I will create the tracer in the client and server when reading the 
properties.



##########
ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java:
##########
@@ -94,6 +104,36 @@ public static <T, THROWABLE extends Throwable> 
CompletableFuture<T> traceAsyncMe
     return enabled ? traceAsyncMethod(action, request, memberId, spanName) : 
action.get();
   }
 
+  public static <T, THROWABLE extends Throwable> CompletableFuture<T> 
traceAsyncImplSend(
+      CheckedSupplier<CompletableFuture<T>, THROWABLE> action,
+      RaftClientRequest.Type type, RaftPeerId server) throws THROWABLE {
+    return isTraceEnabled() ? traceAsyncClientSend(action, type, server, 
"AsyncImpl::send") : action.get();
+  }
+
+  private static boolean isTraceEnabled() {
+    return TraceConfigKeys.enabled(PROPERTIES);
+  }
+
+  public static <T, THROWABLE extends Throwable> CompletableFuture<T> 
traceAsyncClientSend(
+      CheckedSupplier<CompletableFuture<T>, THROWABLE> action,
+      RaftClientRequest.Type type, RaftPeerId server, String spanName) throws 
THROWABLE {
+    return traceAsyncMethod(action, () -> createClientOperationSpan(type, 
server, spanName));
+  }

Review Comment:
   The suggestion is good, I should have refactored them and keep the new 
classes in ratis-common



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

Reply via email to