Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect hard-coded env var name in Java tracer configurator #382

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading