Skip to content

Commit 032d63c

Browse files
authored
Log found cipher suites (#2173)
* Log found cipher suites * Add JVM info * More startup logging * Spotless * Remove unnecessary info
1 parent 295279d commit 032d63c

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/common/NetworkFriendlyExceptions.java

+22-6
Original file line numberDiff line numberDiff line change
@@ -228,24 +228,40 @@ public boolean detect(Throwable error) {
228228
@Override
229229
public String message(String url) {
230230
return FriendlyException.populateFriendlyMessage(
231-
"Probable root cause may be : missing cipher suites which are expected by the requested target.",
231+
"JVM appears to be missing cipher suites which are supported by the endpoint.",
232232
getCipherFriendlyExceptionAction(url),
233233
getFriendlyExceptionBanner(url),
234234
"This message is only logged the first time it occurs after startup.");
235235
}
236236

237-
private static String getCipherFriendlyExceptionAction(String url) {
237+
private String getCipherFriendlyExceptionAction(String url) {
238238
StringBuilder actionBuilder = new StringBuilder();
239239
actionBuilder
240240
.append(
241-
"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: "
241+
"The JVM does not have any of the cipher suites that are supported by the endpoint "
242242
+ url)
243-
.append("\n");
243+
.append("\n\n");
244244
for (String missingCipher : EXPECTED_CIPHERS) {
245-
actionBuilder.append(missingCipher).append("\n");
245+
actionBuilder.append(" ").append(missingCipher).append("\n");
246246
}
247247
actionBuilder.append(
248-
"Learn more about troubleshooting this network issue related to cipher suites here: https://go.microsoft.com/fwlink/?linkid=2185426");
248+
"\nHere are the cipher suites that the JVM does have, in case this is"
249+
+ " helpful in identifying why the ones above are missing:\n");
250+
for (String foundCipher : cipherSuitesFromJvm) {
251+
actionBuilder.append(foundCipher).append("\n");
252+
}
253+
// even though we log this info at startup, this info is particularly important for this error
254+
// so we duplicate it here to make sure we get it as quickly and as easily as possible
255+
actionBuilder.append(
256+
"\nJava version:"
257+
+ System.getProperty("java.version")
258+
+ ", vendor: "
259+
+ System.getProperty("java.vendor")
260+
+ ", home: "
261+
+ System.getProperty("java.home"));
262+
actionBuilder.append(
263+
"\nLearn more about troubleshooting this network issue related to cipher suites here:"
264+
+ " https://go.microsoft.com/fwlink/?linkid=2185426");
249265
return actionBuilder.toString();
250266
}
251267
}

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/MainEntryPoint.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ public static void start(Instrumentation instrumentation, File javaagentFile) {
101101
"ApplicationInsights Java Agent {} started successfully (PID {})",
102102
agentVersion,
103103
new PidFinder().getValue());
104+
startupLogger.info(
105+
"Java version: {}, vendor: {}, home: {}",
106+
System.getProperty("java.version"),
107+
System.getProperty("java.vendor"),
108+
System.getProperty("java.home"));
104109
success = true;
105110
LoggerFactory.getLogger(DiagnosticsHelper.DIAGNOSTICS_LOGGER_NAME)
106111
.info("Application Insights Codeless Agent {} Attach Successful", agentVersion);
@@ -109,7 +114,12 @@ public static void start(Instrumentation instrumentation, File javaagentFile) {
109114
} catch (Throwable t) {
110115

111116
FriendlyException friendlyException = getFriendlyException(t);
112-
String banner = "ApplicationInsights Java Agent " + agentVersion + " failed to start";
117+
String banner =
118+
"ApplicationInsights Java Agent "
119+
+ agentVersion
120+
+ " failed to start (PID "
121+
+ new PidFinder().getValue()
122+
+ ")";
113123
if (friendlyException != null) {
114124
logErrorMessage(
115125
startupLogger, friendlyException.getMessageWithBanner(banner), true, t, javaagentFile);

0 commit comments

Comments
 (0)