diff --git a/src/main/java/org/datadog/jenkins/plugins/datadog/apm/DatadogTracerConfigurator.java b/src/main/java/org/datadog/jenkins/plugins/datadog/apm/DatadogTracerConfigurator.java index 6dfd89c4..b3c41e30 100644 --- a/src/main/java/org/datadog/jenkins/plugins/datadog/apm/DatadogTracerConfigurator.java +++ b/src/main/java/org/datadog/jenkins/plugins/datadog/apm/DatadogTracerConfigurator.java @@ -111,6 +111,7 @@ private static TopLevelItem getTopLevelItem(Run run) { private static Map getCommonEnvVariables(DatadogGlobalConfiguration datadogConfig, DatadogTracerJobProperty tracerConfig) { Map variables = new HashMap<>(); + variables.put("DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER", "jenkins"); variables.put("DD_CIVISIBILITY_ENABLED", "true"); variables.put("DD_ENV", "ci"); variables.put("DD_SERVICE", tracerConfig.getServiceName()); diff --git a/src/main/java/org/datadog/jenkins/plugins/datadog/apm/JavaConfigurator.java b/src/main/java/org/datadog/jenkins/plugins/datadog/apm/JavaConfigurator.java index da6c7831..d54c918a 100644 --- a/src/main/java/org/datadog/jenkins/plugins/datadog/apm/JavaConfigurator.java +++ b/src/main/java/org/datadog/jenkins/plugins/datadog/apm/JavaConfigurator.java @@ -16,8 +16,8 @@ import java.util.function.Function; import java.util.logging.Logger; import jenkins.model.Jenkins; -import org.datadog.jenkins.plugins.datadog.clients.HttpClient; import org.datadog.jenkins.plugins.datadog.apm.signature.SignatureVerifier; +import org.datadog.jenkins.plugins.datadog.clients.HttpClient; final class JavaConfigurator implements TracerConfigurator { @@ -153,12 +153,11 @@ private static Map getEnvVariables(DatadogTracerJobProperty t Map variables = new HashMap<>(); String tracerAgent = "-javaagent:" + tracerFile.getRemote(); - variables.put("MAVEN_OPTS", PropertyUtils.prepend(envs, "MAVEN_OPTS", tracerAgent)); - variables.put("GRADLE_OPTS", PropertyUtils.prepend(envs, "GRADLE_OPTS", "-Dorg.gradle.jvmargs=" + tracerAgent)); + variables.put("JAVA_TOOL_OPTIONS", PropertyUtils.prepend(envs, "JAVA_TOOL_OPTIONS", tracerAgent)); String proxyConfiguration = getProxyConfiguration(tracerConfig, node); if (proxyConfiguration != null) { - variables.put("JAVA_TOOL_OPTIONS", PropertyUtils.prepend(envs, "JAVA_TOOL_OPTIONS", proxyConfiguration)); + variables.put("JAVA_TOOL_OPTIONS", PropertyUtils.prepend(variables, "JAVA_TOOL_OPTIONS", proxyConfiguration)); } Map additionalVariables = tracerConfig.getAdditionalVariables(); @@ -197,19 +196,19 @@ private static String getProxyConfiguration(DatadogTracerJobProperty tracerCo StringBuilder proxyOptions = new StringBuilder(); if (proxyHost != null) { - proxyOptions.append("-Dhttp.proxyHost=").append(proxyHost); + proxyOptions.append("-Dhttp.proxyHost=").append(proxyHost).append(" "); } if (proxyPort > 0) { - proxyOptions.append("-Dhttp.proxyPort=").append(proxyPort); + proxyOptions.append("-Dhttp.proxyPort=").append(proxyPort).append(" "); } if (noProxyHost != null) { - proxyOptions.append("-Dhttp.nonProxyHosts=").append(noProxyHost); + proxyOptions.append("-Dhttp.nonProxyHosts=").append(noProxyHost).append(" "); } if (userName != null) { - proxyOptions.append("-Dhttp.proxyUser=").append(userName); + proxyOptions.append("-Dhttp.proxyUser=").append(userName).append(" "); } if (password != null) { - proxyOptions.append("-Dhttp.proxyPassword=").append(Secret.toString(password)); + proxyOptions.append("-Dhttp.proxyPassword=").append(Secret.toString(password)).append(" "); } return proxyOptions.length() > 0 ? proxyOptions.toString() : null; } diff --git a/src/main/resources/org/datadog/jenkins/plugins/datadog/apm/DatadogTracerJobProperty/help-languages.html b/src/main/resources/org/datadog/jenkins/plugins/datadog/apm/DatadogTracerJobProperty/help-languages.html index 84e8215a..73fca3ea 100644 --- a/src/main/resources/org/datadog/jenkins/plugins/datadog/apm/DatadogTracerJobProperty/help-languages.html +++ b/src/main/resources/org/datadog/jenkins/plugins/datadog/apm/DatadogTracerJobProperty/help-languages.html @@ -7,12 +7,12 @@ Java

Injection works for any JVM-based language (Java, Kotlin, Groovy, Scala, etc). - Any Maven or Gradle build that the job executes will be traced. + Any Java process will be traced.

- MAVEN_OPTS and GRADLE_OPTS environment variables are used for injection. - If these variables are overridden inside the job (with their existing value being discarded rather than preserved), - the injection will not happen. + JAVA_TOOL_OPTIONS environment variable is used for injection. + If this variable is overridden inside the job (with its existing value being discarded rather than preserved), + the injection will not work.

JS