From c0c393c196132c600c6370853a04b2d03bc2e37f Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Thu, 17 Nov 2022 15:16:00 +0100 Subject: [PATCH 1/2] Add JAVA_OPTS and JAVA_TOOL_OPTIONS to the self diagnostics --- .../agent/internal/init/FirstEntryPoint.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/FirstEntryPoint.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/FirstEntryPoint.java index 0e0130d3641..e9149b474ac 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/FirstEntryPoint.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/FirstEntryPoint.java @@ -102,9 +102,7 @@ public void init() { if (startupLogger.isDebugEnabled()) { startupLogger.debug("OS: " + System.getProperty("os.name")); - startupLogger.debug("Classpath: " + System.getProperty("java.class.path")); - startupLogger.debug( - "Input arguments: " + ManagementFactory.getRuntimeMXBean().getInputArguments()); + logJavaInfo(); } } catch (Exception e) { @@ -112,6 +110,20 @@ public void init() { } } + private static void logJavaInfo() { + startupLogger.debug("Classpath: " + System.getProperty("java.class.path")); + startupLogger.debug( + "Input arguments: " + ManagementFactory.getRuntimeMXBean().getInputArguments()); + String javaOpts = System.getenv("JAVA_OPTS"); + if (javaOpts != null) { + startupLogger.debug("JAVA_OPTS: " + javaOpts); + } + String javaToolOptions = System.getenv("JAVA_TOOL_OPTIONS"); + if (javaToolOptions != null) { + startupLogger.debug("JAVA_TOOL_OPTIONS: " + javaToolOptions); + } + } + @Override public void onStartupSuccess() { startupLogger.info( From 5c546b66a7aa56818e2649bb40127bc86f8423bb Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Fri, 18 Nov 2022 12:24:22 +0100 Subject: [PATCH 2/2] Add other Java-related environment variables to the self-diagnostics --- .../agent/internal/init/FirstEntryPoint.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/FirstEntryPoint.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/FirstEntryPoint.java index e9149b474ac..48bdaca0e3b 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/FirstEntryPoint.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/FirstEntryPoint.java @@ -114,14 +114,14 @@ private static void logJavaInfo() { startupLogger.debug("Classpath: " + System.getProperty("java.class.path")); startupLogger.debug( "Input arguments: " + ManagementFactory.getRuntimeMXBean().getInputArguments()); - String javaOpts = System.getenv("JAVA_OPTS"); - if (javaOpts != null) { - startupLogger.debug("JAVA_OPTS: " + javaOpts); - } - String javaToolOptions = System.getenv("JAVA_TOOL_OPTIONS"); - if (javaToolOptions != null) { - startupLogger.debug("JAVA_TOOL_OPTIONS: " + javaToolOptions); - } + startupLogger.debug( + "JAVA_OPTS: " + + System.getenv("JAVA_OPTS") + + ", _JAVA_OPTIONS: " + + System.getenv("_JAVA_OPTIONS") + + ", JAVA_OPTIONS: " + + System.getenv("JAVA_OPTIONS")); + startupLogger.debug("JAVA_TOOL_OPTIONS: " + System.getenv("JAVA_TOOL_OPTIONS")); } @Override