Add start-up diagnostics#2500
Conversation
…ights/agent/internal/init/StartupDiagnostics.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
| "applicationinsights.debug.rss.enabled"; | ||
|
|
||
| // Execute with -XX:NativeMemoryTracking=summary | ||
| private static final String APPLICATIONINSIGHTS_DEBUG_NATIVE_MEM_TRACKING_ENABLED = | ||
| "applicationinsights.debug.native-mem-tracking.enabled"; | ||
|
|
||
| public static final String APPLICATIONINSIGHTS_DEBUG_DIAG_EXPORT_TO_FILE = | ||
| "applicationinsights.debug.diag-export-to-file"; |
There was a problem hiding this comment.
maybe applicationinsights.debug.* -> applicationinsights.debug.startup.*, or applicationinsights.debug.startup-*?
| byte[] diagReportAsBytes = diagnosticsReport.toString().getBytes(StandardCharsets.UTF_8); | ||
| try { | ||
| Files.write(diagFile.toPath(), diagReportAsBytes); |
There was a problem hiding this comment.
| byte[] diagReportAsBytes = diagnosticsReport.toString().getBytes(StandardCharsets.UTF_8); | |
| try { | |
| Files.write(diagFile.toPath(), diagReportAsBytes); | |
| try { | |
| Files.writeString(diagFile.toPath(), diagnosticsReport.toString()); |
There was a problem hiding this comment.
@trask Files.writeString is not availlable in Java 8: https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html
| } | ||
| } | ||
|
|
||
| private Optional<File> createTempDirIfNotExists() { |
There was a problem hiding this comment.
typically this repo (and upstream otel) uses @Nullable over Optional, though not totally consistently, it's not a problem to introduce here, but let's have broader discussion separately over whether we want to go in that direction generally
| } | ||
|
|
||
| private static IllegalStateException combineExceptionsIfNecessary( | ||
| IllegalStateException exitValueException, Exception e, List<String> command) { |
There was a problem hiding this comment.
| IllegalStateException exitValueException, Exception e, List<String> command) { | |
| @Nullable IllegalStateException exitValueException, Exception e, List<String> command) { |
| if (e.getSuppressed().length == 1) { | ||
| return e.getMessage() + " (Suppressed: " + e.getSuppressed()[0] + ")"; | ||
| } |
There was a problem hiding this comment.
The suppressed message doesn't seem like it would be very interesting typically, and this would allow still getting the full stack trace along with suppressed exception if really needed at debug level.
| if (e.getSuppressed().length == 1) { | |
| return e.getMessage() + " (Suppressed: " + e.getSuppressed()[0] + ")"; | |
| } | |
| startupLogger.debug(e.getMessage(), e); |
| // ] | ||
| private static final String | ||
| APPLICATIONINSIGHTS_EXPERIMENT_CLEAR_COMPILER_DIRECTIVES_AFTER_INITIALIZATION = | ||
| "applicationinsights.experiment.clear-compiler-directives-after-initialization"; |
There was a problem hiding this comment.
| "applicationinsights.experiment.clear-compiler-directives-after-initialization"; | |
| "applicationinsights.experiment.clear_compiler_directives_after_initialization"; |
There was a problem hiding this comment.
should we follow the same naming convention? i have seen lost of underline instead of dash. See AiSemanticAttributes.java
There was a problem hiding this comment.
this is a system property name, and not a semantic attribute name
|
|
||
| // Execute with -XX:NativeMemoryTracking=summary | ||
| private static final String APPLICATIONINSIGHTS_DEBUG_NATIVE_MEM_TRACKING_ENABLED = | ||
| "applicationinsights.debug.native-mem-tracking.enabled"; |
There was a problem hiding this comment.
| "applicationinsights.debug.native-mem-tracking.enabled"; | |
| "applicationinsights.debug.native_mem_tracking_enabled"; |
|
|
||
| static boolean hasToDisableJvmCompilerDirectives() { | ||
| return Boolean.getBoolean( | ||
| APPLICATIONINSIGHTS_EXPERIMENT_CLEAR_COMPILER_DIRECTIVES_AFTER_INITIALIZATION); |
There was a problem hiding this comment.
such a long system property name, should we consider a shorter name?
There was a problem hiding this comment.
this is a hard one to explain succinctly 😅
|
|
||
| class JvmCompiler { | ||
|
|
||
| // To disable C2 compiler during Application Insights set-up, for Java >= 9, do the following |
There was a problem hiding this comment.
can you add a note how user can use APPLICATIONINSIGHTS_EXPERIMENT_CLEAR_COMPILER_DIRECTIVES_AFTER_INITIALIZATION?
There was a problem hiding this comment.
@heyamsthis It's an experimental feature that we would like to test with some users. Following the feedbacks, we could properly document this feature.
There was a problem hiding this comment.
@heyams It is necessary to add the JVM option explained from line 11 and set the applicationinsights.experiment.clear-compiler-directives-after-initialization property to true.
…ights/agent/internal/init/StartupDiagnostics.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…ights/agent/internal/init/StartupDiagnostics.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…ights/agent/internal/init/StartupDiagnostics.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…and the ability to disable the JVM C2 compiler during start-up (#2500)
…and the ability to disable the JVM C2 compiler during start-up (#2500)
…and the ability to disable the JVM C2 compiler during start-up (#2500)
Add start-up diagnostics: