13
13
import static datadog .trace .util .Strings .propertyNameToSystemPropertyName ;
14
14
import static datadog .trace .util .Strings .toEnvVar ;
15
15
16
+ import datadog .environment .EnvironmentVariables ;
16
17
import datadog .environment .JavaVirtualMachine ;
17
18
import datadog .environment .OperatingSystem ;
19
+ import datadog .environment .SystemProperties ;
18
20
import datadog .trace .api .Config ;
19
21
import datadog .trace .api .Platform ;
20
22
import datadog .trace .api .StatsDClientManager ;
@@ -269,7 +271,7 @@ public static void start(
269
271
propertyNameToSystemPropertyName ("integration.spark-openlineage.enabled" ), "true" );
270
272
}
271
273
272
- String javaCommand = System . getProperty ( "sun.java.command" );
274
+ String javaCommand = String . join ( " " , JavaVirtualMachine . getCommandArguments () );
273
275
String dataJobsCommandPattern = Config .get ().getDataJobsCommandPattern ();
274
276
if (!isDataJobsSupported (javaCommand , dataJobsCommandPattern )) {
275
277
log .warn (
@@ -283,8 +285,8 @@ public static void start(
283
285
if (!isSupportedAppSecArch ()) {
284
286
log .debug (
285
287
"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" ));
288
290
setSystemPropertyDefault (AgentFeature .APPSEC .getSystemProp (), "false" );
289
291
}
290
292
@@ -950,7 +952,7 @@ private static void startAppSec(SubscriptionService ss, Class<?> scoClass, Objec
950
952
}
951
953
952
954
private static boolean isSupportedAppSecArch () {
953
- final String arch = System . getProperty ("os.arch" );
955
+ final String arch = SystemProperties . get ("os.arch" );
954
956
if (OperatingSystem .isWindows ()) {
955
957
// TODO: Windows bindings need to be built for x86
956
958
return "amd64" .equals (arch ) || "x86_64" .equals (arch );
@@ -1260,13 +1262,7 @@ public void withTracer(TracerAPI tracer) {
1260
1262
}
1261
1263
1262
1264
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 ();
1270
1266
}
1271
1267
1272
1268
private static void shutdownProfilingAgent (final boolean sync ) {
@@ -1333,7 +1329,8 @@ private static synchronized void startDebuggerAgent(
1333
1329
private static void configureLogger () {
1334
1330
setSystemPropertyDefault (SIMPLE_LOGGER_SHOW_DATE_TIME_PROPERTY , "true" );
1335
1331
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" )) {
1337
1334
setSystemPropertyDefault (
1338
1335
SIMPLE_LOGGER_DATE_TIME_FORMAT_PROPERTY , SIMPLE_LOGGER_DATE_TIME_FORMAT_JSON_DEFAULT );
1339
1336
} else {
@@ -1347,7 +1344,7 @@ private static void configureLogger() {
1347
1344
} else {
1348
1345
logLevel = ddGetProperty ("dd.log.level" );
1349
1346
if (null == logLevel ) {
1350
- logLevel = System . getenv ("OTEL_LOG_LEVEL" );
1347
+ logLevel = EnvironmentVariables . get ("OTEL_LOG_LEVEL" );
1351
1348
}
1352
1349
}
1353
1350
@@ -1361,8 +1358,8 @@ private static void configureLogger() {
1361
1358
}
1362
1359
1363
1360
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 );
1366
1363
}
1367
1364
}
1368
1365
@@ -1383,7 +1380,7 @@ private static ClassLoader getPlatformClassLoader()
1383
1380
*/
1384
1381
private static boolean isDebugMode () {
1385
1382
final String tracerDebugLevelSysprop = "dd.trace.debug" ;
1386
- final String tracerDebugLevelProp = System . getProperty (tracerDebugLevelSysprop );
1383
+ final String tracerDebugLevelProp = SystemProperties . get (tracerDebugLevelSysprop );
1387
1384
1388
1385
if (tracerDebugLevelProp != null ) {
1389
1386
return Boolean .parseBoolean (tracerDebugLevelProp );
@@ -1402,7 +1399,7 @@ private static boolean isFeatureEnabled(AgentFeature feature) {
1402
1399
// must be kept in sync with logic from Config!
1403
1400
final String featureConfigKey = feature .getConfigKey ();
1404
1401
final String featureSystemProp = feature .getSystemProp ();
1405
- String featureEnabled = System . getProperty (featureSystemProp );
1402
+ String featureEnabled = SystemProperties . get (featureSystemProp );
1406
1403
if (featureEnabled == null ) {
1407
1404
featureEnabled = getStableConfig (StableConfigSource .FLEET , featureConfigKey );
1408
1405
}
@@ -1432,7 +1429,7 @@ private static boolean isFullyDisabled(final AgentFeature feature) {
1432
1429
// must be kept in sync with logic from Config!
1433
1430
final String featureConfigKey = feature .getConfigKey ();
1434
1431
final String featureSystemProp = feature .getSystemProp ();
1435
- String settingValue = getNullIfEmpty (System . getProperty (featureSystemProp ));
1432
+ String settingValue = getNullIfEmpty (SystemProperties . get (featureSystemProp ));
1436
1433
if (settingValue == null ) {
1437
1434
settingValue = getNullIfEmpty (getStableConfig (StableConfigSource .FLEET , featureConfigKey ));
1438
1435
}
@@ -1489,7 +1486,7 @@ private static int getJmxStartDelay() {
1489
1486
*/
1490
1487
private static boolean isAppUsingCustomLogManager (final EnumSet <Library > libraries ) {
1491
1488
final String tracerCustomLogManSysprop = "dd.app.customlogmanager" ;
1492
- final String customLogManagerProp = System . getProperty (tracerCustomLogManSysprop );
1489
+ final String customLogManagerProp = SystemProperties . get (tracerCustomLogManSysprop );
1493
1490
final String customLogManagerEnv = ddGetEnv (tracerCustomLogManSysprop );
1494
1491
1495
1492
if (customLogManagerProp != null || customLogManagerEnv != null ) {
@@ -1504,7 +1501,7 @@ private static boolean isAppUsingCustomLogManager(final EnumSet<Library> librari
1504
1501
return true ; // Wildfly is known to set a custom log manager after startup.
1505
1502
}
1506
1503
1507
- final String logManagerProp = System . getProperty ("java.util.logging.manager" );
1504
+ final String logManagerProp = SystemProperties . get ("java.util.logging.manager" );
1508
1505
if (logManagerProp != null ) {
1509
1506
log .debug ("Prop - logging.manager: {}" , logManagerProp );
1510
1507
return true ;
@@ -1521,7 +1518,7 @@ private static boolean isAppUsingCustomLogManager(final EnumSet<Library> librari
1521
1518
*/
1522
1519
private static boolean isAppUsingCustomJMXBuilder (final EnumSet <Library > libraries ) {
1523
1520
final String tracerCustomJMXBuilderSysprop = "dd.app.customjmxbuilder" ;
1524
- final String customJMXBuilderProp = System . getProperty (tracerCustomJMXBuilderSysprop );
1521
+ final String customJMXBuilderProp = SystemProperties . get (tracerCustomJMXBuilderSysprop );
1525
1522
final String customJMXBuilderEnv = ddGetEnv (tracerCustomJMXBuilderSysprop );
1526
1523
1527
1524
if (customJMXBuilderProp != null || customJMXBuilderEnv != null ) {
@@ -1536,7 +1533,7 @@ private static boolean isAppUsingCustomJMXBuilder(final EnumSet<Library> librari
1536
1533
return true ; // Wildfly is known to set a custom JMX builder after startup.
1537
1534
}
1538
1535
1539
- final String jmxBuilderProp = System . getProperty ("javax.management.builder.initial" );
1536
+ final String jmxBuilderProp = SystemProperties . get ("javax.management.builder.initial" );
1540
1537
if (jmxBuilderProp != null ) {
1541
1538
log .debug ("Prop - javax.management.builder.initial: {}" , jmxBuilderProp );
1542
1539
return true ;
@@ -1547,7 +1544,7 @@ private static boolean isAppUsingCustomJMXBuilder(final EnumSet<Library> librari
1547
1544
1548
1545
/** Looks for the "dd." system property first then the "DD_" environment variable equivalent. */
1549
1546
private static String ddGetProperty (final String sysProp ) {
1550
- String value = System . getProperty (sysProp );
1547
+ String value = SystemProperties . get (sysProp );
1551
1548
if (null == value ) {
1552
1549
value = ddGetEnv (sysProp );
1553
1550
}
@@ -1561,7 +1558,7 @@ private static String getStableConfig(StableConfigSource source, final String sy
1561
1558
1562
1559
/** Looks for the "DD_" environment variable equivalent of the given "dd." system property. */
1563
1560
private static String ddGetEnv (final String sysProp ) {
1564
- return System . getenv (toEnvVar (sysProp ));
1561
+ return EnvironmentVariables . get (toEnvVar (sysProp ));
1565
1562
}
1566
1563
1567
1564
private static boolean okHttpMayIndirectlyLoadJUL () {
0 commit comments