From 8ff2c62aaffa9b98901b0857cdc06e4954844e97 Mon Sep 17 00:00:00 2001 From: James McMullan Date: Wed, 18 Sep 2024 11:21:20 -0400 Subject: [PATCH] HPCC4J-647 FileUtility only use otel autosdk without javaagent (#758) Signed-off-by: James McMullan James.McMullan@lexisnexis.com --- .../java/org/hpccsystems/dfs/client/FileUtility.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java b/dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java index 8e87a24ce..254665b7c 100644 --- a/dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java +++ b/dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java @@ -75,7 +75,7 @@ public class FileUtility private static final int NUM_DEFAULT_THREADS = 4; static private final int DEFAULT_ACCESS_EXPIRY_SECONDS = 120; - private static boolean otelInitialized = false; + private static boolean otelNeedsInit = true; private static class TaskContext { @@ -1973,7 +1973,7 @@ private static void performWrite(String[] args, TaskContext context) */ public static JSONArray run(String[] args) { - if (!otelInitialized) + if (otelNeedsInit) { if (Boolean.getBoolean("otel.java.global-autoconfigure.enabled")) { @@ -1989,10 +1989,13 @@ public static JSONArray run(String[] args) System.out.println(" otel.metrics.exporter: "+ System.getProperty("otel.metrics.exporter")); System.out.println(" OTEL_METRICS_EXPORTER Env var: " + System.getenv("OTEL_METRICS_EXPORTER")); - OpenTelemetry otel = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk(); + if (!org.hpccsystems.ws.client.utils.Utils.isOtelJavaagentUsed()) + { + AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk(); + } } - otelInitialized = true; + otelNeedsInit = false; } Options options = getTopLevelOptions();