@@ -129,6 +129,12 @@ public class ConfigurationBuilder {
129129 public static Configuration create (Path agentJarPath , @ Nullable RpConfiguration rpConfiguration )
130130 throws IOException {
131131 Configuration config = loadConfigurationFile (agentJarPath );
132+ logConfigurationWarnings (config );
133+ overlayConfiguration (agentJarPath , rpConfiguration , config );
134+ return config ;
135+ }
136+
137+ private static void logConfigurationWarnings (Configuration config ) {
132138 if (config .instrumentation .micrometer .reportingIntervalSeconds != 60 ) {
133139 configurationLogger .warn (
134140 "micrometer \" reportingIntervalSeconds\" setting leaked out previously"
@@ -185,7 +191,10 @@ public static Configuration create(Path agentJarPath, @Nullable RpConfiguration
185191 + " so no need to enable it under preview configuration" );
186192 }
187193 logWarningIfUsingInternalAttributes (config );
194+ }
188195
196+ private static void overlayConfiguration (
197+ Path agentJarPath , RpConfiguration rpConfiguration , Configuration config ) throws IOException {
189198 overlayFromEnv (config , agentJarPath .getParent ());
190199 config .sampling .percentage = roundToNearest (config .sampling .percentage , true );
191200 for (SamplingOverride override : config .preview .sampling .overrides ) {
@@ -202,7 +211,6 @@ public static Configuration create(Path agentJarPath, @Nullable RpConfiguration
202211 String hostname = HostName .get ();
203212 config .role .instance = hostname == null ? "unknown" : hostname ;
204213 }
205- return config ;
206214 }
207215
208216 private static void logWarningIfUsingInternalAttributes (Configuration config ) {
@@ -246,13 +254,23 @@ private static void logWarningIfUsingInternalAttributes(String attributeKey) {
246254 }
247255
248256 private static void overlayProfilerEnvVars (Configuration config ) {
257+ if (isOpenJ9Jvm ()) {
258+ configurationLogger .warn (
259+ "Profiler is not supported for an OpenJ9 JVM. Instead, please use an OpenJDK JVM." );
260+ config .preview .profiler .enabled = false ;
261+ }
249262 config .preview .profiler .enabled =
250263 Boolean .parseBoolean (
251264 overlayWithEnvVar (
252265 APPLICATIONINSIGHTS_PREVIEW_PROFILER_ENABLED ,
253266 Boolean .toString (config .preview .profiler .enabled )));
254267 }
255268
269+ private static boolean isOpenJ9Jvm () {
270+ String jvmName = System .getProperty ("java.vm.name" );
271+ return jvmName != null && jvmName .contains ("OpenJ9" );
272+ }
273+
256274 private static void overlayAadEnvVars (Configuration config ) {
257275 String aadAuthString = getEnvVar (APPLICATIONINSIGHTS_AUTHENTICATION_STRING );
258276 if (aadAuthString != null ) {
0 commit comments