From 032d63ce2d840179efcf37fb41f816a6c121e9b3 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 10 Mar 2022 19:59:08 -0800 Subject: [PATCH] Log found cipher suites (#2173) * Log found cipher suites * Add JVM info * More startup logging * Spotless * Remove unnecessary info --- .../common/NetworkFriendlyExceptions.java | 28 +++++++++++++++---- .../agent/internal/init/MainEntryPoint.java | 12 +++++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/common/NetworkFriendlyExceptions.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/common/NetworkFriendlyExceptions.java index 7c82daed7a4..888b1ea130e 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/common/NetworkFriendlyExceptions.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/common/NetworkFriendlyExceptions.java @@ -228,24 +228,40 @@ public boolean detect(Throwable error) { @Override public String message(String url) { return FriendlyException.populateFriendlyMessage( - "Probable root cause may be : missing cipher suites which are expected by the requested target.", + "JVM appears to be missing cipher suites which are supported by the endpoint.", getCipherFriendlyExceptionAction(url), getFriendlyExceptionBanner(url), "This message is only logged the first time it occurs after startup."); } - private static String getCipherFriendlyExceptionAction(String url) { + private String getCipherFriendlyExceptionAction(String url) { StringBuilder actionBuilder = new StringBuilder(); actionBuilder .append( - "The Application Insights Java agent detects that you do not have any of the following cipher suites that are supported by the endpoint it connects to: " + "The JVM does not have any of the cipher suites that are supported by the endpoint " + url) - .append("\n"); + .append("\n\n"); for (String missingCipher : EXPECTED_CIPHERS) { - actionBuilder.append(missingCipher).append("\n"); + actionBuilder.append(" ").append(missingCipher).append("\n"); } actionBuilder.append( - "Learn more about troubleshooting this network issue related to cipher suites here: https://go.microsoft.com/fwlink/?linkid=2185426"); + "\nHere are the cipher suites that the JVM does have, in case this is" + + " helpful in identifying why the ones above are missing:\n"); + for (String foundCipher : cipherSuitesFromJvm) { + actionBuilder.append(foundCipher).append("\n"); + } + // even though we log this info at startup, this info is particularly important for this error + // so we duplicate it here to make sure we get it as quickly and as easily as possible + actionBuilder.append( + "\nJava version:" + + System.getProperty("java.version") + + ", vendor: " + + System.getProperty("java.vendor") + + ", home: " + + System.getProperty("java.home")); + actionBuilder.append( + "\nLearn more about troubleshooting this network issue related to cipher suites here:" + + " https://go.microsoft.com/fwlink/?linkid=2185426"); return actionBuilder.toString(); } } diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/MainEntryPoint.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/MainEntryPoint.java index c0e645d75ac..36273edf248 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/MainEntryPoint.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/MainEntryPoint.java @@ -101,6 +101,11 @@ public static void start(Instrumentation instrumentation, File javaagentFile) { "ApplicationInsights Java Agent {} started successfully (PID {})", agentVersion, new PidFinder().getValue()); + startupLogger.info( + "Java version: {}, vendor: {}, home: {}", + System.getProperty("java.version"), + System.getProperty("java.vendor"), + System.getProperty("java.home")); success = true; LoggerFactory.getLogger(DiagnosticsHelper.DIAGNOSTICS_LOGGER_NAME) .info("Application Insights Codeless Agent {} Attach Successful", agentVersion); @@ -109,7 +114,12 @@ public static void start(Instrumentation instrumentation, File javaagentFile) { } catch (Throwable t) { FriendlyException friendlyException = getFriendlyException(t); - String banner = "ApplicationInsights Java Agent " + agentVersion + " failed to start"; + String banner = + "ApplicationInsights Java Agent " + + agentVersion + + " failed to start (PID " + + new PidFinder().getValue() + + ")"; if (friendlyException != null) { logErrorMessage( startupLogger, friendlyException.getMessageWithBanner(banner), true, t, javaagentFile);