Pil0tXia commented on code in PR #3632:
URL: https://github.com/apache/eventmesh/pull/3632#discussion_r1636907854


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/Trace.java:
##########
@@ -111,7 +112,17 @@ public Span addTraceInfoToSpan(ChannelHandlerContext ctx, 
CloudEvent cloudEvent)
         }
         Context context = 
ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).get();
         Span span = context != null ? context.get(SpanKey.SERVER_KEY) : null;
-        return addTraceInfoToSpan(span, cloudEvent);
+
+        if (span == null) {
+            log.warn("span is null when finishSpan");
+            return null;
+        }
+
+        //add trace info
+        for (String entry : cloudEvent.getExtensionNames()) {
+            span.setAttribute(entry, cloudEvent.getExtension(entry) == null ? 
"" : Objects.requireNonNull(cloudEvent.getExtension(entry)).toString());
+        }
+        return span;

Review Comment:
   Why do we need to inline the `addTraceInfoToSpan` method here? I think it is 
enough to add a `requireNonNull` method in the "add trace info" step of 
`addTraceInfoToSpan` method.



-- 
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: issues-unsubscr...@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@eventmesh.apache.org
For additional commands, e-mail: issues-h...@eventmesh.apache.org

Reply via email to