Skip to content

Commit a0be9c9

Browse files
committed
Merge remote-tracking branch 'origin/master' into maven-proxy-fixes
2 parents 5eac6a9 + 0b95f68 commit a0be9c9

25 files changed

Lines changed: 251 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
public final class AgentBootstrap {
4747
static final String LIB_INJECTION_ENABLED_ENV_VAR = "DD_INJECTION_ENABLED";
4848
static final String LIB_INJECTION_FORCE_SYS_PROP = "dd.inject.force";
49+
static final String LIB_INSTRUMENTATION_SOURCE_SYS_PROP = "dd.instrumentation.source";
4950

5051
private static final Class<?> thisClass = AgentBootstrap.class;
5152
private static final int MAX_EXCEPTION_CHAIN_LENGTH = 99;
@@ -134,6 +135,12 @@ private static void agentmainImpl(
134135
return;
135136
}
136137

138+
if (getConfig(LIB_INJECTION_ENABLED_ENV_VAR)) {
139+
recordInstrumentationSource("ssi");
140+
} else {
141+
recordInstrumentationSource("cmd_line");
142+
}
143+
137144
final URL agentJarURL = installAgentJar(inst);
138145
final Class<?> agentClass;
139146
try {
@@ -164,6 +171,10 @@ static boolean getConfig(String configName) {
164171
}
165172
}
166173

174+
private static void recordInstrumentationSource(String source) {
175+
SystemUtils.trySetProperty(LIB_INSTRUMENTATION_SOURCE_SYS_PROP, source);
176+
}
177+
167178
static boolean exceptionCauseChainContains(Throwable ex, String exClassName) {
168179
Set<Throwable> stack = Collections.newSetFromMap(new IdentityHashMap<>());
169180
Throwable t = ex;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public static String tryGetProperty(String property) {
2323
}
2424
}
2525

26+
public static String trySetProperty(String property, String value) {
27+
try {
28+
return System.setProperty(property, value);
29+
} catch (SecurityException e) {
30+
return null;
31+
}
32+
}
33+
2634
public static String getPropertyOrDefault(String property, String defaultValue) {
2735
try {
2836
return System.getProperty(property, defaultValue);

dd-smoke-tests/gradle/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ test {
1818
events "passed", "skipped", "failed", "standardOut", "standardError"
1919
}
2020

21+
if (project.hasProperty("mavenRepositoryProxy")) {
22+
// propagate proxy URL to tests, to then propagate it to nested Gradle builds
23+
environment "MAVEN_REPOSITORY_PROXY", project.property("mavenRepositoryProxy")
24+
}
25+
2126
// overriding the default timeout of 9 minutes set in configure_tests.gradle,
2227
// as Gradle smoke tests might run for a longer duration
2328
timeout = Duration.of(15, ChronoUnit.MINUTES)

dd-smoke-tests/gradle/src/test/groovy/datadog/smoketest/GradleDaemonSmokeTest.groovy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,19 @@ class GradleDaemonSmokeTest extends AbstractGradleTest {
239239
}
240240

241241
private runGradle(String gradleVersion, List<String> arguments, boolean successExpected) {
242+
def buildEnv = ["GRADLE_VERSION": gradleVersion]
243+
244+
def mavenRepositoryProxy = System.getenv("MAVEN_REPOSITORY_PROXY")
245+
if (mavenRepositoryProxy != null) {
246+
buildEnv += ["MAVEN_REPOSITORY_PROXY": System.getenv("MAVEN_REPOSITORY_PROXY")]
247+
}
248+
242249
GradleRunner gradleRunner = GradleRunner.create()
243250
.withTestKitDir(testKitFolder.toFile())
244251
.withProjectDir(projectFolder.toFile())
245252
.withGradleVersion(gradleVersion)
246253
.withArguments(arguments)
247-
.withEnvironment(["GRADLE_VERSION": gradleVersion])
254+
.withEnvironment(buildEnv)
248255
.forwardOutput()
249256

250257
println "${new Date()}: $specificationContext.currentIteration.displayName - Starting Gradle run"

dd-smoke-tests/gradle/src/test/resources/test-corrupted-config-legacy-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-corrupted-config-new-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-failed-flaky-retries/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-failed-legacy-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-failed-new-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-skip-legacy-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

0 commit comments

Comments
 (0)