jojochuang commented on code in PR #11723:
URL: https://github.com/apache/ozone/pull/11723#discussion_r4364788858
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java:
##########
@@ -191,11 +197,49 @@ private static void initialize(String serviceName,
TracingConfig cfg, boolean is
return;
}
+ if (!tracingEnabled) {
+ // Application-aware only: spans are created only under a valid parent,
which most client processes never have.
+ // Build Ozone's SDK (exporter, export thread, global registration) when
the first such span needs it.
+ pendingSdkServiceName = serviceName;
+ pendingSdkConfig = cfg;
+ return;
+ }
+
// No app-supplied global — build Ozone's SDK and always register it as
the JVM global,
// so any co-resident library observes the same tracer whenever tracing is
valid.
initOzoneSdk(serviceName, cfg, true);
}
+ /**
+ * Completes application-aware initialization left pending by {@link
#initialize}: adopts an application
+ * GlobalOpenTelemetry registered since then, or builds Ozone's SDK. Called
before creating a span with a parent.
+ */
+ private static void initPendingSdk() {
+ if (pendingSdkConfig == null) {
+ return;
+ }
+ synchronized (TracingUtil.class) {
+ final TracingConfig cfg = pendingSdkConfig;
+ if (cfg == null) {
+ return;
+ }
+ try {
+ if (GlobalOpenTelemetry.isSet() &&
isRealGlobal(GlobalOpenTelemetry.get())) {
+ tracer = GlobalOpenTelemetry.get().getTracer(GLOBAL_TRACER_NAME);
Review Comment:
[P2] Handle the default global installed during deferred initialization
After deferred initialization, another library can call
`GlobalOpenTelemetry.get()` before Ozone's first traced operation.
OpenTelemetry 1.67.0 installs a wrapper around its no-op implementation, which
passes `isRealGlobal()` because the wrapper differs from
`OpenTelemetry.noop()`. This branch adopts the no-op tracer and permanently
clears pending initialization, silently losing subsequent Ozone child spans
even with valid parents. Previously, Ozone had already installed its
functioning SDK before that read. Handle this wrapped default global and add
coverage for `initTracing()`, `GlobalOpenTelemetry.get()`, then a valid parent
span.
Reference: [OpenTelemetry 1.67.0
GlobalOpenTelemetry](https://github.com/open-telemetry/opentelemetry-java/blob/v1.67.0/api/all/src/main/java/io/opentelemetry/api/GlobalOpenTelemetry.java).
--
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]