Skip to content

Commit 430807e

Browse files
committed
modify to reduce code duplication
1 parent 1a0f038 commit 430807e

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,13 @@ public static void start(final Instrumentation inst, final URL agentJarURL, Stri
204204

205205
boolean dataJobsEnabled = isFeatureEnabled(AgentFeature.DATA_JOBS);
206206
if (dataJobsEnabled) {
207-
if (!isDataJobsSupported()) {
207+
String javaCommand = System.getProperty("sun.java.command");
208+
String dataJobsCommandPattern = Config.get().getDataJobsCommandPattern();
209+
if (!isDataJobsSupported(javaCommand, dataJobsCommandPattern)) {
208210
log.warn(
209211
"Data Jobs Monitoring is not compatible with non-spark command {} based on command pattern {}. dd-trace-java will not be installed",
210-
System.getProperty("sun.java.command"),
211-
Config.get().getDataJobsCommandPattern());
212+
javaCommand,
213+
dataJobsCommandPattern);
212214
return;
213215
}
214216

@@ -1316,10 +1318,7 @@ private static boolean isJFRSupported() {
13161318
return BootstrapProxy.INSTANCE.getResource("jdk/jfr/Recording.class") != null;
13171319
}
13181320

1319-
private static boolean isDataJobsSupported() {
1320-
String javaCommand = System.getProperty("sun.java.command");
1321-
String dataJobsCommandPattern = Config.get().getDataJobsCommandPattern();
1322-
1321+
private static boolean isDataJobsSupported(String javaCommand, String dataJobsCommandPattern) {
13231322
if (null == javaCommand || null == dataJobsCommandPattern) {
13241323
// if sun.java.command somehow is not set or data jobs command pattern is not
13251324
// set, assume it's supported due to lack of info.

dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/AbstractDatadogSparkListener.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ private void initApplicationSpanIfNotInitialized() {
162162
builder
163163
.withStartTimestamp(applicationStart.time() * 1000)
164164
.withTag("application_name", applicationStart.appName())
165-
.withTag("spark_user", applicationStart.sparkUser())
166-
.withTag("_dd.spark.java.command", System.getProperty("sun.java.command"));
165+
.withTag("spark_user", applicationStart.sparkUser());
167166

168167
if (applicationStart.appAttemptId().isDefined()) {
169168
builder.withTag("app_attempt_id", applicationStart.appAttemptId().get());
@@ -332,8 +331,7 @@ public synchronized void onJobStart(SparkListenerJobStart jobStart) {
332331
buildSparkSpan("spark.job", jobStart.properties())
333332
.withStartTimestamp(jobStart.time() * 1000)
334333
.withTag("job_id", jobStart.jobId())
335-
.withTag("stage_count", getStageCount(jobStart))
336-
.withTag("_dd.spark.java.command", System.getProperty("sun.java.command"));
334+
.withTag("stage_count", getStageCount(jobStart));
337335

338336
String batchKey = getStreamingBatchKey(jobStart.properties());
339337
Long sqlExecutionId = getSqlExecutionId(jobStart.properties());

0 commit comments

Comments
 (0)