Skip to content

Commit

Permalink
Fix incorrect hard-coded env var name in Java tracer configurator (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-tkachenko-datadog authored Feb 2, 2024
1 parent 250a3c5 commit 4f5ca11
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;
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;

final class JavaConfigurator implements TracerConfigurator {

private static final Logger LOGGER = Logger.getLogger(DatadogTracerConfigurator.class.getName());

private static final String TRACER_DISTRIBUTION_URL_ENV_VAR = "DATADOG_JENKINS_PLUGIN_TRACER_DISTRIBUTION_URL";
private static final String DEFAULT_TRACER_DISTRIBUTION_URL = "https://dtdg.co/latest-java-tracer";
private static final String TRACER_FILE_NAME = "dd-java-agent.jar";
Expand Down Expand Up @@ -98,7 +101,12 @@ private byte[] getTracerSignaturePublicKey(DatadogTracerJobProperty<?> tracerCon
private <T> T getSetting(DatadogTracerJobProperty<?> tracerConfig, String envVariableName, T defaultValue, Function<String, T> parser) {
String envVariable = getEnvVariable(tracerConfig, envVariableName);
if (envVariable != null) {
return parser.apply(envVariable);
try {
return parser.apply(envVariable);
} catch (Exception e) {
LOGGER.fine("Variable " + envVariableName + " has value which could not be parsed. " +
"Will use default value " + defaultValue);
}
}
return defaultValue;
}
Expand All @@ -111,7 +119,7 @@ private String getEnvVariable(DatadogTracerJobProperty<?> tracerConfig, String n
return envVariable;
}
}
return System.getenv(TRACER_JAR_CACHE_TTL_ENV_VAR);
return System.getenv(name);
}

private String validateUserSuppliedTracerUrl(String distributionUrl) {
Expand Down

0 comments on commit 4f5ca11

Please sign in to comment.