szetszwo commented on code in PR #1443:
URL: https://github.com/apache/ratis/pull/1443#discussion_r3190584487


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -558,7 +568,28 @@ PendingRequest addPendingRequest(PendingRequests.Permit 
permit, RaftClientReques
       LOG.debug("{}: addPendingRequest at {}, entry={}", this, request,
           LogProtoUtils.toLogEntryString(entry.getLogEntry()));
     }
-    return pendingRequests.add(permit, request, entry);
+    final PendingRequest pending = pendingRequests.add(permit, request, entry);
+    if (pending != null && TraceUtils.isEnabled()) {
+      final SpanContextProto spanContext = request.getSpanContext();
+      if (spanContext != null && !spanContext.getContextMap().isEmpty()) {
+        replicationTraceByLogIndex.put(pending.getTermIndex().getIndex(), 
spanContext);
+      }
+    }
+    return pending;
+  }
+
+  private static SpanContextProto 
tracingContextForReplication(List<LogEntryProto> entries,
+      ConcurrentHashMap<Long, SpanContextProto> traceByIndex) {
+    if (entries == null || entries.isEmpty()) {
+      return null;
+    }
+    for (LogEntryProto e : entries) {
+      final SpanContextProto sc = traceByIndex.get(e.getIndex());
+      if (sc != null && !sc.getContextMap().isEmpty()) {
+        return sc;
+      }
+    }

Review Comment:
   Since entries is a list, there could be multiple PendingRequest(s).  Should 
we return multiple SpanContextProto(s)?



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