4
4
import static datadog .environment .JavaVirtualMachine .isOracleJDK8 ;
5
5
import static datadog .trace .api .ConfigDefaults .DEFAULT_STARTUP_LOGS_ENABLED ;
6
6
import static datadog .trace .api .telemetry .LogCollector .SEND_TELEMETRY ;
7
+ import static datadog .trace .api .config .GeneralConfig .DATA_JOBS_COMMAND_PATTERN ;
8
+ import static datadog .trace .api .config .GeneralConfig .DATA_JOBS_ENABLED ;
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,42 @@ 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 = ddGetProperty (propertyNameToSystemPropertyName (DATA_JOBS_COMMAND_PATTERN ));
415
+ if (!isDataJobsSupported (javaCommand , dataJobsCommandPattern )) {
416
+ log .warn (
417
+ "Data Jobs Monitoring is not compatible with non-spark command {} based on command pattern {}. dd-trace-java will not be installed" ,
418
+ javaCommand ,
419
+ dataJobsCommandPattern );
420
+ return false ;
421
+ }
422
+ }
423
+ return true ;
424
+ }
425
+
449
426
private static void injectAgentArgsConfig (String agentArgs ) {
450
427
try {
451
428
final Class <?> agentArgsInjectorClass =
@@ -458,6 +435,45 @@ private static void injectAgentArgsConfig(String agentArgs) {
458
435
}
459
436
}
460
437
438
+ private static void configureCiVisibility (URL agentJarURL ) {
439
+ // Retro-compatibility for the old way to configure CI Visibility
440
+ if ("true" .equals (ddGetProperty ("dd.integration.junit.enabled" ))
441
+ || "true" .equals (ddGetProperty ("dd.integration.testng.enabled" ))) {
442
+ setSystemPropertyDefault (AgentFeature .CIVISIBILITY .getSystemProp (), "true" );
443
+ }
444
+
445
+ ciVisibilityEnabled = isFeatureEnabled (AgentFeature .CIVISIBILITY );
446
+ if (ciVisibilityEnabled ) {
447
+ // if CI Visibility is enabled, all the other features are disabled by default
448
+ // unless the user had explicitly enabled them.
449
+ setSystemPropertyDefault (AgentFeature .JMXFETCH .getSystemProp (), "false" );
450
+ setSystemPropertyDefault (AgentFeature .PROFILING .getSystemProp (), "false" );
451
+ setSystemPropertyDefault (AgentFeature .APPSEC .getSystemProp (), "false" );
452
+ setSystemPropertyDefault (AgentFeature .IAST .getSystemProp (), "false" );
453
+ setSystemPropertyDefault (AgentFeature .REMOTE_CONFIG .getSystemProp (), "false" );
454
+ setSystemPropertyDefault (AgentFeature .CWS .getSystemProp (), "false" );
455
+
456
+ /*if CI Visibility is enabled, the PrioritizationType should be {@code Prioritization.ENSURE_TRACE} */
457
+ setSystemPropertyDefault (
458
+ propertyNameToSystemPropertyName (TracerConfig .PRIORITIZATION_TYPE ), "ENSURE_TRACE" );
459
+
460
+ try {
461
+ setSystemPropertyDefault (
462
+ propertyNameToSystemPropertyName (CiVisibilityConfig .CIVISIBILITY_AGENT_JAR_URI ),
463
+ agentJarURL .toURI ().toString ());
464
+ } catch (URISyntaxException e ) {
465
+ throw new IllegalArgumentException (
466
+ "Could not create URI from agent JAR URL: " + agentJarURL , e );
467
+ }
468
+ }
469
+
470
+ // Enable automatic fetching of git tags from datadog_git.properties only if CI Visibility is
471
+ // not enabled
472
+ if (!ciVisibilityEnabled ) {
473
+ GitInfoProvider .INSTANCE .registerGitInfoBuilder (new EmbeddedGitInfoBuilder ());
474
+ }
475
+ }
476
+
461
477
public static void shutdown (final boolean sync ) {
462
478
StaticEventLogger .end ("Agent" );
463
479
StaticEventLogger .stop ();
@@ -1401,13 +1417,13 @@ private static boolean isFeatureEnabled(AgentFeature feature) {
1401
1417
final String featureSystemProp = feature .getSystemProp ();
1402
1418
String featureEnabled = SystemProperties .get (featureSystemProp );
1403
1419
if (featureEnabled == null ) {
1404
- featureEnabled = getStableConfig (StableConfigSource . FLEET , featureConfigKey );
1420
+ featureEnabled = getStableConfig (FLEET , featureConfigKey );
1405
1421
}
1406
1422
if (featureEnabled == null ) {
1407
1423
featureEnabled = ddGetEnv (featureSystemProp );
1408
1424
}
1409
1425
if (featureEnabled == null ) {
1410
- featureEnabled = getStableConfig (StableConfigSource . LOCAL , featureConfigKey );
1426
+ featureEnabled = getStableConfig (LOCAL , featureConfigKey );
1411
1427
}
1412
1428
1413
1429
if (feature .isEnabledByDefault ()) {
@@ -1431,13 +1447,13 @@ private static boolean isFullyDisabled(final AgentFeature feature) {
1431
1447
final String featureSystemProp = feature .getSystemProp ();
1432
1448
String settingValue = getNullIfEmpty (SystemProperties .get (featureSystemProp ));
1433
1449
if (settingValue == null ) {
1434
- settingValue = getNullIfEmpty (getStableConfig (StableConfigSource . FLEET , featureConfigKey ));
1450
+ settingValue = getNullIfEmpty (getStableConfig (FLEET , featureConfigKey ));
1435
1451
}
1436
1452
if (settingValue == null ) {
1437
1453
settingValue = getNullIfEmpty (ddGetEnv (featureSystemProp ));
1438
1454
}
1439
1455
if (settingValue == null ) {
1440
- settingValue = getNullIfEmpty (getStableConfig (StableConfigSource . LOCAL , featureConfigKey ));
1456
+ settingValue = getNullIfEmpty (getStableConfig (LOCAL , featureConfigKey ));
1441
1457
}
1442
1458
1443
1459
// defaults to inactive
0 commit comments