1313import static datadog .trace .util .Strings .propertyNameToSystemPropertyName ;
1414import static datadog .trace .util .Strings .toEnvVar ;
1515
16+ import datadog .environment .EnvironmentVariables ;
1617import datadog .environment .JavaVirtualMachine ;
1718import datadog .environment .OperatingSystem ;
19+ import datadog .environment .SystemProperties ;
1820import datadog .trace .api .Config ;
1921import datadog .trace .api .Platform ;
2022import datadog .trace .api .StatsDClientManager ;
@@ -269,7 +271,7 @@ public static void start(
269271 propertyNameToSystemPropertyName ("integration.spark-openlineage.enabled" ), "true" );
270272 }
271273
272- String javaCommand = System . getProperty ( "sun.java.command" );
274+ String javaCommand = String . join ( " " , JavaVirtualMachine . getCommandArguments () );
273275 String dataJobsCommandPattern = Config .get ().getDataJobsCommandPattern ();
274276 if (!isDataJobsSupported (javaCommand , dataJobsCommandPattern )) {
275277 log .warn (
@@ -283,8 +285,8 @@ public static void start(
283285 if (!isSupportedAppSecArch ()) {
284286 log .debug (
285287 "OS and architecture ({}/{}) not supported by AppSec, dd.appsec.enabled will default to false" ,
286- System . getProperty ("os.name" ),
287- System . getProperty ("os.arch" ));
288+ SystemProperties . get ("os.name" ),
289+ SystemProperties . get ("os.arch" ));
288290 setSystemPropertyDefault (AgentFeature .APPSEC .getSystemProp (), "false" );
289291 }
290292
@@ -950,7 +952,7 @@ private static void startAppSec(SubscriptionService ss, Class<?> scoClass, Objec
950952 }
951953
952954 private static boolean isSupportedAppSecArch () {
953- final String arch = System . getProperty ("os.arch" );
955+ final String arch = SystemProperties . get ("os.arch" );
954956 if (OperatingSystem .isWindows ()) {
955957 // TODO: Windows bindings need to be built for x86
956958 return "amd64" .equals (arch ) || "x86_64" .equals (arch );
@@ -1260,13 +1262,7 @@ public void withTracer(TracerAPI tracer) {
12601262 }
12611263
12621264 private static boolean isAwsLambdaRuntime () {
1263- String val = System .getenv ("AWS_LAMBDA_FUNCTION_NAME" );
1264- return val != null && !val .isEmpty ();
1265- }
1266-
1267- private static ScopeListener createScopeListener (String className ) throws Throwable {
1268- return (ScopeListener )
1269- AGENT_CLASSLOADER .loadClass (className ).getDeclaredConstructor ().newInstance ();
1265+ return !EnvironmentVariables .getOrDefault ("AWS_LAMBDA_FUNCTION_NAME" , "" ).isEmpty ();
12701266 }
12711267
12721268 private static void shutdownProfilingAgent (final boolean sync ) {
@@ -1333,7 +1329,8 @@ private static synchronized void startDebuggerAgent(
13331329 private static void configureLogger () {
13341330 setSystemPropertyDefault (SIMPLE_LOGGER_SHOW_DATE_TIME_PROPERTY , "true" );
13351331 setSystemPropertyDefault (SIMPLE_LOGGER_JSON_ENABLED_PROPERTY , "false" );
1336- if (System .getProperty (SIMPLE_LOGGER_JSON_ENABLED_PROPERTY ).equalsIgnoreCase ("true" )) {
1332+ String simpleLoggerJsonEnabled = SystemProperties .get (SIMPLE_LOGGER_JSON_ENABLED_PROPERTY );
1333+ if (simpleLoggerJsonEnabled != null && simpleLoggerJsonEnabled .equalsIgnoreCase ("true" )) {
13371334 setSystemPropertyDefault (
13381335 SIMPLE_LOGGER_DATE_TIME_FORMAT_PROPERTY , SIMPLE_LOGGER_DATE_TIME_FORMAT_JSON_DEFAULT );
13391336 } else {
@@ -1347,7 +1344,7 @@ private static void configureLogger() {
13471344 } else {
13481345 logLevel = ddGetProperty ("dd.log.level" );
13491346 if (null == logLevel ) {
1350- logLevel = System . getenv ("OTEL_LOG_LEVEL" );
1347+ logLevel = EnvironmentVariables . get ("OTEL_LOG_LEVEL" );
13511348 }
13521349 }
13531350
@@ -1361,8 +1358,8 @@ private static void configureLogger() {
13611358 }
13621359
13631360 private static void setSystemPropertyDefault (final String property , final String value ) {
1364- if (System . getProperty (property ) == null && ddGetEnv (property ) == null ) {
1365- System . setProperty (property , value );
1361+ if (SystemProperties . get (property ) == null && ddGetEnv (property ) == null ) {
1362+ SystemProperties . set (property , value );
13661363 }
13671364 }
13681365
@@ -1383,7 +1380,7 @@ private static ClassLoader getPlatformClassLoader()
13831380 */
13841381 private static boolean isDebugMode () {
13851382 final String tracerDebugLevelSysprop = "dd.trace.debug" ;
1386- final String tracerDebugLevelProp = System . getProperty (tracerDebugLevelSysprop );
1383+ final String tracerDebugLevelProp = SystemProperties . get (tracerDebugLevelSysprop );
13871384
13881385 if (tracerDebugLevelProp != null ) {
13891386 return Boolean .parseBoolean (tracerDebugLevelProp );
@@ -1402,7 +1399,7 @@ private static boolean isFeatureEnabled(AgentFeature feature) {
14021399 // must be kept in sync with logic from Config!
14031400 final String featureConfigKey = feature .getConfigKey ();
14041401 final String featureSystemProp = feature .getSystemProp ();
1405- String featureEnabled = System . getProperty (featureSystemProp );
1402+ String featureEnabled = SystemProperties . get (featureSystemProp );
14061403 if (featureEnabled == null ) {
14071404 featureEnabled = getStableConfig (StableConfigSource .FLEET , featureConfigKey );
14081405 }
@@ -1432,7 +1429,7 @@ private static boolean isFullyDisabled(final AgentFeature feature) {
14321429 // must be kept in sync with logic from Config!
14331430 final String featureConfigKey = feature .getConfigKey ();
14341431 final String featureSystemProp = feature .getSystemProp ();
1435- String settingValue = getNullIfEmpty (System . getProperty (featureSystemProp ));
1432+ String settingValue = getNullIfEmpty (SystemProperties . get (featureSystemProp ));
14361433 if (settingValue == null ) {
14371434 settingValue = getNullIfEmpty (getStableConfig (StableConfigSource .FLEET , featureConfigKey ));
14381435 }
@@ -1489,7 +1486,7 @@ private static int getJmxStartDelay() {
14891486 */
14901487 private static boolean isAppUsingCustomLogManager (final EnumSet <Library > libraries ) {
14911488 final String tracerCustomLogManSysprop = "dd.app.customlogmanager" ;
1492- final String customLogManagerProp = System . getProperty (tracerCustomLogManSysprop );
1489+ final String customLogManagerProp = SystemProperties . get (tracerCustomLogManSysprop );
14931490 final String customLogManagerEnv = ddGetEnv (tracerCustomLogManSysprop );
14941491
14951492 if (customLogManagerProp != null || customLogManagerEnv != null ) {
@@ -1504,7 +1501,7 @@ private static boolean isAppUsingCustomLogManager(final EnumSet<Library> librari
15041501 return true ; // Wildfly is known to set a custom log manager after startup.
15051502 }
15061503
1507- final String logManagerProp = System . getProperty ("java.util.logging.manager" );
1504+ final String logManagerProp = SystemProperties . get ("java.util.logging.manager" );
15081505 if (logManagerProp != null ) {
15091506 log .debug ("Prop - logging.manager: {}" , logManagerProp );
15101507 return true ;
@@ -1521,7 +1518,7 @@ private static boolean isAppUsingCustomLogManager(final EnumSet<Library> librari
15211518 */
15221519 private static boolean isAppUsingCustomJMXBuilder (final EnumSet <Library > libraries ) {
15231520 final String tracerCustomJMXBuilderSysprop = "dd.app.customjmxbuilder" ;
1524- final String customJMXBuilderProp = System . getProperty (tracerCustomJMXBuilderSysprop );
1521+ final String customJMXBuilderProp = SystemProperties . get (tracerCustomJMXBuilderSysprop );
15251522 final String customJMXBuilderEnv = ddGetEnv (tracerCustomJMXBuilderSysprop );
15261523
15271524 if (customJMXBuilderProp != null || customJMXBuilderEnv != null ) {
@@ -1536,7 +1533,7 @@ private static boolean isAppUsingCustomJMXBuilder(final EnumSet<Library> librari
15361533 return true ; // Wildfly is known to set a custom JMX builder after startup.
15371534 }
15381535
1539- final String jmxBuilderProp = System . getProperty ("javax.management.builder.initial" );
1536+ final String jmxBuilderProp = SystemProperties . get ("javax.management.builder.initial" );
15401537 if (jmxBuilderProp != null ) {
15411538 log .debug ("Prop - javax.management.builder.initial: {}" , jmxBuilderProp );
15421539 return true ;
@@ -1547,7 +1544,7 @@ private static boolean isAppUsingCustomJMXBuilder(final EnumSet<Library> librari
15471544
15481545 /** Looks for the "dd." system property first then the "DD_" environment variable equivalent. */
15491546 private static String ddGetProperty (final String sysProp ) {
1550- String value = System . getProperty (sysProp );
1547+ String value = SystemProperties . get (sysProp );
15511548 if (null == value ) {
15521549 value = ddGetEnv (sysProp );
15531550 }
@@ -1561,7 +1558,7 @@ private static String getStableConfig(StableConfigSource source, final String sy
15611558
15621559 /** Looks for the "DD_" environment variable equivalent of the given "dd." system property. */
15631560 private static String ddGetEnv (final String sysProp ) {
1564- return System . getenv (toEnvVar (sysProp ));
1561+ return EnvironmentVariables . get (toEnvVar (sysProp ));
15651562 }
15661563
15671564 private static boolean okHttpMayIndirectlyLoadJUL () {
0 commit comments