Skip to content

Commit

Permalink
Log found cipher suites (#2173)
Browse files Browse the repository at this point in the history
* Log found cipher suites

* Add JVM info

* More startup logging

* Spotless

* Remove unnecessary info
  • Loading branch information
trask authored Mar 11, 2022
1 parent 295279d commit 032d63c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 032d63c

Please sign in to comment.