Skip to content

Commit

Permalink
Only instrument Maven/Gradle/SBT/Ant when doing tests auto-instrument…
Browse files Browse the repository at this point in the history
…ation (#465)
  • Loading branch information
nikita-tkachenko-datadog authored Nov 6, 2024
1 parent aa9f8b4 commit 5184582
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ private static Map<String, String> getEnvVariables(DatadogTracerJobProperty<?> t
Map<String, String> variables = new HashMap<>();

String tracerAgent = "-javaagent:" + tracerFile.getRemote();
variables.put("JAVA_TOOL_OPTIONS", PropertyUtils.prepend(envs, "JAVA_TOOL_OPTIONS", tracerAgent));
variables.put("DD_TRACE_OPTS", PropertyUtils.prepend(envs, "DD_TRACE_OPTS", tracerAgent)); // this var can be used for "semi-automatic" tracer injection (e.g. `JAVA_TOOL_OPTIONS=$DD_TRACE_OPTS`)
variables.put("MAVEN_OPTS", PropertyUtils.prepend(envs, "MAVEN_OPTS", tracerAgent));
variables.put("SBT_OPTS", PropertyUtils.prepend(envs, "SBT_OPTS", tracerAgent));
variables.put("ANT_OPTS", PropertyUtils.prepend(envs, "ANT_OPTS", tracerAgent));
variables.put("GRADLE_OPTS", PropertyUtils.prepend(envs, "GRADLE_OPTS", "-Dorg.gradle.jvmargs=" + tracerAgent));

String proxyConfiguration = getProxyConfiguration(tracerConfig, node);
if (proxyConfiguration != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

<strong>Java</strong>
<p>
Injection works for any JVM-based language (Java, Kotlin, Groovy, Scala, etc).
Any Java process will be traced.
Injection works for Maven, Gradle, SBT, Ant builds and for any JVM-based language (Java, Kotlin, Groovy, Scala, etc).
</p>
<p>
<code>JAVA_TOOL_OPTIONS</code> environment variable is used for injection.
If this variable is overridden inside the job (with its existing value being discarded rather than preserved),
<code>MAVEN_OPTS</code>,<code>GRADLE_OPTS</code>,<code>SBT_OPTS</code>,<code>ANT_OPTS</code> environment variables are used for injection.
If these variables are overridden inside the job (with its existing value being discarded rather than preserved),
the injection will not work.
</p>

Expand Down

0 comments on commit 5184582

Please sign in to comment.