chihsuan commented on code in PR #11607:
URL: https://github.com/apache/ozone/pull/11607#discussion_r4373801374


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/conf/TracingReconfigurationCallback.java:
##########
@@ -45,6 +45,7 @@ private TracingReconfigurationCallback(String serviceName, 
TracingConfig tracing
    */
   public static TracingReconfigurationCallback init(
       String serviceName, TracingConfig tracingConfig) {
+    TracingUtil.installMdcContextStorage();

Review Comment:
   Could we also install this before `omInit`? I found that an OM started with 
`ozone om --bootstrap` logs the WARN and gets no IDs, since `omInit` touches 
the context first. Bootstrap is rare, but the OM keeps running without IDs, so 
a follow-up JIRA works for me if you prefer.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java:
##########
@@ -62,11 +65,29 @@ public final class TracingUtil {
   private static Tracer tracer = OpenTelemetry.noop().getTracer("noop");
   private static volatile SdkTracerProvider sdkTracerProvider;
   private static BatchSpanProcessor batchSpanProcessor;
+  private static boolean mdcContextStorageInstalled;
   public static final String GLOBAL_TRACER_NAME = "ozone";
 
   private TracingUtil() {
   }
 
+  /**
+   * Adds the current trace and span IDs to the logging MDC.
+   * Only for Ozone services and CLIs, not the client library, so applications 
keep their own MDC.
+   * Must be called before OpenTelemetry {@link Context} is first used in the 
JVM.
+   */
+  public static synchronized void installMdcContextStorage() {
+    if (mdcContextStorageInstalled) {
+      return;
+    }
+    mdcContextStorageInstalled = true;
+    ContextStorage.addWrapper(MdcContextStorage::new);

Review Comment:
   It looks like nothing covers this `addWrapper` line yet. Removing it keeps 
all tests green. Could we add a small test class that installs it globally to 
help protect it?



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