3
3
import static datadog .environment .JavaVirtualMachine .isJavaVersionAtLeast ;
4
4
import static datadog .environment .JavaVirtualMachine .isOracleJDK8 ;
5
5
import static datadog .trace .api .ConfigDefaults .DEFAULT_STARTUP_LOGS_ENABLED ;
6
+ import static datadog .trace .api .config .GeneralConfig .DATA_JOBS_COMMAND_PATTERN ;
7
+ import static datadog .trace .api .config .GeneralConfig .DATA_JOBS_ENABLED ;
6
8
import static datadog .trace .api .telemetry .LogCollector .SEND_TELEMETRY ;
7
9
import static datadog .trace .bootstrap .Library .WILDFLY ;
8
10
import static datadog .trace .bootstrap .Library .detectLibraries ;
11
+ import static datadog .trace .bootstrap .config .provider .StableConfigSource .FLEET ;
12
+ import static datadog .trace .bootstrap .config .provider .StableConfigSource .LOCAL ;
9
13
import static datadog .trace .util .AgentThreadFactory .AgentThread .JMX_STARTUP ;
10
14
import static datadog .trace .util .AgentThreadFactory .AgentThread .PROFILER_STARTUP ;
11
15
import static datadog .trace .util .AgentThreadFactory .AgentThread .TRACE_STARTUP ;
@@ -212,74 +216,11 @@ public static void start(
212
216
injectAgentArgsConfig (agentArgs );
213
217
}
214
218
215
- // Retro-compatibility for the old way to configure CI Visibility
216
- if ("true" .equals (ddGetProperty ("dd.integration.junit.enabled" ))
217
- || "true" .equals (ddGetProperty ("dd.integration.testng.enabled" ))) {
218
- setSystemPropertyDefault (AgentFeature .CIVISIBILITY .getSystemProp (), "true" );
219
- }
220
-
221
- ciVisibilityEnabled = isFeatureEnabled (AgentFeature .CIVISIBILITY );
222
- if (ciVisibilityEnabled ) {
223
- // if CI Visibility is enabled, all the other features are disabled by default
224
- // unless the user had explicitly enabled them.
225
- setSystemPropertyDefault (AgentFeature .JMXFETCH .getSystemProp (), "false" );
226
- setSystemPropertyDefault (AgentFeature .PROFILING .getSystemProp (), "false" );
227
- setSystemPropertyDefault (AgentFeature .APPSEC .getSystemProp (), "false" );
228
- setSystemPropertyDefault (AgentFeature .IAST .getSystemProp (), "false" );
229
- setSystemPropertyDefault (AgentFeature .REMOTE_CONFIG .getSystemProp (), "false" );
230
- setSystemPropertyDefault (AgentFeature .CWS .getSystemProp (), "false" );
231
-
232
- /*if CI Visibility is enabled, the PrioritizationType should be {@code Prioritization.ENSURE_TRACE} */
233
- setSystemPropertyDefault (
234
- propertyNameToSystemPropertyName (TracerConfig .PRIORITIZATION_TYPE ), "ENSURE_TRACE" );
235
-
236
- try {
237
- setSystemPropertyDefault (
238
- propertyNameToSystemPropertyName (CiVisibilityConfig .CIVISIBILITY_AGENT_JAR_URI ),
239
- agentJarURL .toURI ().toString ());
240
- } catch (URISyntaxException e ) {
241
- throw new IllegalArgumentException (
242
- "Could not create URI from agent JAR URL: " + agentJarURL , e );
243
- }
244
- }
245
-
246
- // Enable automatic fetching of git tags from datadog_git.properties only if CI Visibility is
247
- // not enabled
248
- if (!ciVisibilityEnabled ) {
249
- GitInfoProvider .INSTANCE .registerGitInfoBuilder (new EmbeddedGitInfoBuilder ());
250
- }
251
-
252
- boolean dataJobsEnabled = isFeatureEnabled (AgentFeature .DATA_JOBS );
253
- if (dataJobsEnabled ) {
254
- log .info ("Data Jobs Monitoring enabled, enabling spark integrations" );
255
-
256
- setSystemPropertyDefault (
257
- propertyNameToSystemPropertyName (TracerConfig .TRACE_LONG_RUNNING_ENABLED ), "true" );
258
- setSystemPropertyDefault (
259
- propertyNameToSystemPropertyName ("integration.spark.enabled" ), "true" );
260
- setSystemPropertyDefault (
261
- propertyNameToSystemPropertyName ("integration.spark-executor.enabled" ), "true" );
262
- // needed for e2e pipeline
263
- setSystemPropertyDefault (propertyNameToSystemPropertyName ("data.streams.enabled" ), "true" );
264
- setSystemPropertyDefault (
265
- propertyNameToSystemPropertyName ("integration.aws-sdk.enabled" ), "true" );
266
- setSystemPropertyDefault (
267
- propertyNameToSystemPropertyName ("integration.kafka.enabled" ), "true" );
219
+ configureCiVisibility (agentJarURL );
268
220
269
- if (Config .get ().isDataJobsOpenLineageEnabled ()) {
270
- setSystemPropertyDefault (
271
- propertyNameToSystemPropertyName ("integration.spark-openlineage.enabled" ), "true" );
272
- }
273
-
274
- String javaCommand = String .join (" " , JavaVirtualMachine .getCommandArguments ());
275
- String dataJobsCommandPattern = Config .get ().getDataJobsCommandPattern ();
276
- if (!isDataJobsSupported (javaCommand , dataJobsCommandPattern )) {
277
- log .warn (
278
- "Data Jobs Monitoring is not compatible with non-spark command {} based on command pattern {}. dd-trace-java will not be installed" ,
279
- javaCommand ,
280
- dataJobsCommandPattern );
281
- return ;
282
- }
221
+ // Halt agent start if DJM is enabled and is not successfully configure
222
+ if (!configureDataJobsMonitoring ()) {
223
+ return ;
283
224
}
284
225
285
226
if (!isSupportedAppSecArch ()) {
@@ -446,6 +387,43 @@ public static void start(
446
387
StaticEventLogger .end ("Agent.start" );
447
388
}
448
389
390
+ private static boolean configureDataJobsMonitoring () {
391
+ boolean dataJobsEnabled = isFeatureEnabled (AgentFeature .DATA_JOBS );
392
+ if (dataJobsEnabled ) {
393
+ log .info ("Data Jobs Monitoring enabled, enabling spark integrations" );
394
+
395
+ setSystemPropertyDefault (
396
+ propertyNameToSystemPropertyName (TracerConfig .TRACE_LONG_RUNNING_ENABLED ), "true" );
397
+ setSystemPropertyDefault (
398
+ propertyNameToSystemPropertyName ("integration.spark.enabled" ), "true" );
399
+ setSystemPropertyDefault (
400
+ propertyNameToSystemPropertyName ("integration.spark-executor.enabled" ), "true" );
401
+ // needed for e2e pipeline
402
+ setSystemPropertyDefault (propertyNameToSystemPropertyName ("data.streams.enabled" ), "true" );
403
+ setSystemPropertyDefault (
404
+ propertyNameToSystemPropertyName ("integration.aws-sdk.enabled" ), "true" );
405
+ setSystemPropertyDefault (
406
+ propertyNameToSystemPropertyName ("integration.kafka.enabled" ), "true" );
407
+
408
+ if ("true" .equals (ddGetProperty (propertyNameToSystemPropertyName (DATA_JOBS_ENABLED )))) {
409
+ setSystemPropertyDefault (
410
+ propertyNameToSystemPropertyName ("integration.spark-openlineage.enabled" ), "true" );
411
+ }
412
+
413
+ String javaCommand = String .join (" " , JavaVirtualMachine .getCommandArguments ());
414
+ String dataJobsCommandPattern =
415
+ ddGetProperty (propertyNameToSystemPropertyName (DATA_JOBS_COMMAND_PATTERN ));
416
+ if (!isDataJobsSupported (javaCommand , dataJobsCommandPattern )) {
417
+ log .warn (
418
+ "Data Jobs Monitoring is not compatible with non-spark command {} based on command pattern {}. dd-trace-java will not be installed" ,
419
+ javaCommand ,
420
+ dataJobsCommandPattern );
421
+ return false ;
422
+ }
423
+ }
424
+ return true ;
425
+ }
426
+
449
427
private static void injectAgentArgsConfig (String agentArgs ) {
450
428
try {
451
429
final Class <?> agentArgsInjectorClass =
@@ -458,6 +436,45 @@ private static void injectAgentArgsConfig(String agentArgs) {
458
436
}
459
437
}
460
438
439
+ private static void configureCiVisibility (URL agentJarURL ) {
440
+ // Retro-compatibility for the old way to configure CI Visibility
441
+ if ("true" .equals (ddGetProperty ("dd.integration.junit.enabled" ))
442
+ || "true" .equals (ddGetProperty ("dd.integration.testng.enabled" ))) {
443
+ setSystemPropertyDefault (AgentFeature .CIVISIBILITY .getSystemProp (), "true" );
444
+ }
445
+
446
+ ciVisibilityEnabled = isFeatureEnabled (AgentFeature .CIVISIBILITY );
447
+ if (ciVisibilityEnabled ) {
448
+ // if CI Visibility is enabled, all the other features are disabled by default
449
+ // unless the user had explicitly enabled them.
450
+ setSystemPropertyDefault (AgentFeature .JMXFETCH .getSystemProp (), "false" );
451
+ setSystemPropertyDefault (AgentFeature .PROFILING .getSystemProp (), "false" );
452
+ setSystemPropertyDefault (AgentFeature .APPSEC .getSystemProp (), "false" );
453
+ setSystemPropertyDefault (AgentFeature .IAST .getSystemProp (), "false" );
454
+ setSystemPropertyDefault (AgentFeature .REMOTE_CONFIG .getSystemProp (), "false" );
455
+ setSystemPropertyDefault (AgentFeature .CWS .getSystemProp (), "false" );
456
+
457
+ /*if CI Visibility is enabled, the PrioritizationType should be {@code Prioritization.ENSURE_TRACE} */
458
+ setSystemPropertyDefault (
459
+ propertyNameToSystemPropertyName (TracerConfig .PRIORITIZATION_TYPE ), "ENSURE_TRACE" );
460
+
461
+ try {
462
+ setSystemPropertyDefault (
463
+ propertyNameToSystemPropertyName (CiVisibilityConfig .CIVISIBILITY_AGENT_JAR_URI ),
464
+ agentJarURL .toURI ().toString ());
465
+ } catch (URISyntaxException e ) {
466
+ throw new IllegalArgumentException (
467
+ "Could not create URI from agent JAR URL: " + agentJarURL , e );
468
+ }
469
+ }
470
+
471
+ // Enable automatic fetching of git tags from datadog_git.properties only if CI Visibility is
472
+ // not enabled
473
+ if (!ciVisibilityEnabled ) {
474
+ GitInfoProvider .INSTANCE .registerGitInfoBuilder (new EmbeddedGitInfoBuilder ());
475
+ }
476
+ }
477
+
461
478
public static void shutdown (final boolean sync ) {
462
479
StaticEventLogger .end ("Agent" );
463
480
StaticEventLogger .stop ();
@@ -1401,13 +1418,13 @@ private static boolean isFeatureEnabled(AgentFeature feature) {
1401
1418
final String featureSystemProp = feature .getSystemProp ();
1402
1419
String featureEnabled = SystemProperties .get (featureSystemProp );
1403
1420
if (featureEnabled == null ) {
1404
- featureEnabled = getStableConfig (StableConfigSource . FLEET , featureConfigKey );
1421
+ featureEnabled = getStableConfig (FLEET , featureConfigKey );
1405
1422
}
1406
1423
if (featureEnabled == null ) {
1407
1424
featureEnabled = ddGetEnv (featureSystemProp );
1408
1425
}
1409
1426
if (featureEnabled == null ) {
1410
- featureEnabled = getStableConfig (StableConfigSource . LOCAL , featureConfigKey );
1427
+ featureEnabled = getStableConfig (LOCAL , featureConfigKey );
1411
1428
}
1412
1429
1413
1430
if (feature .isEnabledByDefault ()) {
@@ -1431,13 +1448,13 @@ private static boolean isFullyDisabled(final AgentFeature feature) {
1431
1448
final String featureSystemProp = feature .getSystemProp ();
1432
1449
String settingValue = getNullIfEmpty (SystemProperties .get (featureSystemProp ));
1433
1450
if (settingValue == null ) {
1434
- settingValue = getNullIfEmpty (getStableConfig (StableConfigSource . FLEET , featureConfigKey ));
1451
+ settingValue = getNullIfEmpty (getStableConfig (FLEET , featureConfigKey ));
1435
1452
}
1436
1453
if (settingValue == null ) {
1437
1454
settingValue = getNullIfEmpty (ddGetEnv (featureSystemProp ));
1438
1455
}
1439
1456
if (settingValue == null ) {
1440
- settingValue = getNullIfEmpty (getStableConfig (StableConfigSource . LOCAL , featureConfigKey ));
1457
+ settingValue = getNullIfEmpty (getStableConfig (LOCAL , featureConfigKey ));
1441
1458
}
1442
1459
1443
1460
// defaults to inactive
0 commit comments