Gargi-jais11 commented on code in PR #9908:
URL: https://github.com/apache/ozone/pull/9908#discussion_r2922063833


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java:
##########
@@ -179,10 +179,19 @@ public static boolean isTracingEnabled(
 
   /**
    * Execute {@code runnable} inside an activated new span.
+   * If a parent span exists in the current context, this becomes a child span.
    */
   public static <E extends Exception> void executeInNewSpan(String spanName,
       CheckedRunnable<E> runnable) throws E {
-    Span span = tracer.spanBuilder(spanName).setNoParent().startSpan();
+    Span span;
+    Context currentContext = Context.current();
+    Span parentSpan = Span.fromContext(currentContext);
+
+    if (parentSpan != null && parentSpan.getSpanContext().isValid()) {
+      span = 
tracer.spanBuilder(spanName).setParent(currentContext).startSpan();
+    } else {
+      span = tracer.spanBuilder(spanName).setNoParent().startSpan();
+    }

Review Comment:
   This seems to be duplicated. Let's extract this to a new 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: [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