Skip to content

Commit fce06c1

Browse files
Merge branch 'master' into daniel.mohedano/pr-info-ci-spec
2 parents 6a94235 + 5810407 commit fce06c1

File tree

25 files changed

+1275
-217
lines changed

25 files changed

+1275
-217
lines changed

.circleci/upload_ciapp.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
SERVICE_NAME="dd-trace-java"
3-
PIPELINE_STAGE=$1
3+
CACHE_TYPE=$1
44
TEST_JVM=$2
55

66
# JAVA_???_HOME are set in the base image for each used JDK https://github.com/DataDog/dd-trace-java-docker-build/blob/master/Dockerfile#L86
@@ -23,7 +23,7 @@ junit_upload() {
2323
DD_API_KEY=$1 \
2424
datadog-ci junit upload --service $SERVICE_NAME \
2525
--logs \
26-
--tags "test.traits:{\"marker\":[\"$PIPELINE_STAGE\"]}" \
26+
--tags "test.traits:{\"category\":[\"$CACHE_TYPE\"]}" \
2727
--tags "runtime.name:$(java_prop java.runtime.name)" \
2828
--tags "runtime.vendor:$(java_prop java.vendor)" \
2929
--tags "runtime.version:$(java_prop java.version)" \

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ muzzle-dep-report:
406406
- .circleci/collect_reports.sh
407407
- if [ "$PROFILE_TESTS" == "true" ]; then .circleci/collect_profiles.sh; fi
408408
- .circleci/collect_results.sh
409-
- .circleci/upload_ciapp.sh tests $testJvm
409+
- .circleci/upload_ciapp.sh $CACHE_TYPE $testJvm
410410
- gitlab_section_end "collect-reports"
411411
- URL_ENCODED_JOB_NAME=$(jq -rn --arg x "$CI_JOB_NAME" '$x|@uri')
412412
- echo -e "${TEXT_BOLD}${TEXT_YELLOW}See test results in Datadog:${TEXT_CLEAR} https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40test.service%3Add-trace-java%20%40ci.pipeline.id%3A${CI_PIPELINE_ID}%20%40ci.job.name%3A%22${URL_ENCODED_JOB_NAME}%22"
Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1 @@
1-
plugins {
2-
id 'java-test-fixtures'
3-
}
4-
5-
muzzle {
6-
pass {
7-
group = 'io.servicetalk'
8-
module = 'servicetalk-concurrent-api'
9-
// prev versions missing ContextMap
10-
versions = '[0.41.12,)'
11-
assertInverse = true
12-
}
13-
pass {
14-
group = 'io.servicetalk'
15-
module = 'servicetalk-context-api'
16-
versions = '[0.1.0,)'
17-
assertInverse = true
18-
}
19-
}
20-
21-
ext {
22-
minJavaVersionForTests = JavaVersion.VERSION_11
23-
}
24-
251
apply from: "$rootDir/gradle/java.gradle"
26-
27-
addTestSuiteForDir('latestDepTest', 'test')
28-
29-
dependencies {
30-
compileOnly group: 'io.servicetalk', name: 'servicetalk-concurrent-api', version: '0.42.45'
31-
compileOnly group: 'io.servicetalk', name: 'servicetalk-context-api', version: '0.42.45'
32-
33-
testImplementation group: 'io.servicetalk', name: 'servicetalk-concurrent-api', version: '0.42.0'
34-
testImplementation group: 'io.servicetalk', name: 'servicetalk-context-api', version: '0.42.0'
35-
36-
latestDepTestImplementation group: 'io.servicetalk', name: 'servicetalk-concurrent-api', version: '+'
37-
latestDepTestImplementation group: 'io.servicetalk', name: 'servicetalk-context-api', version: '+'
38-
}
39-

dd-java-agent/instrumentation/servicetalk/gradle.lockfile

Lines changed: 119 additions & 145 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id 'java-test-fixtures'
3+
}
4+
5+
muzzle {
6+
pass {
7+
group = 'io.servicetalk'
8+
module = 'servicetalk-concurrent-api'
9+
versions = '[0.42.0,0.42.55]'
10+
}
11+
fail {
12+
group = 'io.servicetalk'
13+
module = 'servicetalk-concurrent-api'
14+
versions = '(0.42.55,]'
15+
}
16+
}
17+
18+
ext {
19+
minJavaVersionForTests = JavaVersion.VERSION_11
20+
}
21+
22+
apply from: "$rootDir/gradle/java.gradle"
23+
24+
addTestSuiteForDir('latestDepTest', 'test')
25+
26+
dependencies {
27+
compileOnly group: 'io.servicetalk', name: 'servicetalk-concurrent-api', version: '0.42.0'
28+
compileOnly group: 'io.servicetalk', name: 'servicetalk-context-api', version: '0.42.0'
29+
30+
testImplementation group: 'io.servicetalk', name: 'servicetalk-concurrent-api', version: '0.42.42'
31+
testImplementation group: 'io.servicetalk', name: 'servicetalk-context-api', version: '0.42.42'
32+
33+
// import the newer instrumentation into the test to ensure that it does not interfere with it
34+
testRuntimeOnly project(":dd-java-agent:instrumentation:servicetalk:servicetalk-0.42.56")
35+
36+
latestDepTestImplementation group: 'io.servicetalk', name: 'servicetalk-concurrent-api', version: '0.42.55'
37+
latestDepTestImplementation group: 'io.servicetalk', name: 'servicetalk-context-api', version: '0.42.55'
38+
}
39+

dd-java-agent/instrumentation/servicetalk/servicetalk-0.42.0/gradle.lockfile

Lines changed: 185 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datadog.trace.instrumentation.servicetalk;
1+
package datadog.trace.instrumentation.servicetalk0_42_0;
22

33
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
44
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
@@ -16,7 +16,7 @@
1616
import net.bytebuddy.asm.Advice;
1717

1818
@AutoService(InstrumenterModule.class)
19-
public class ContextMapInstrumentation extends AbstractAsyncContextInstrumentation
19+
public class ContextMapInstrumentation extends ServiceTalkInstrumentation
2020
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {
2121

2222
@Override
@@ -40,6 +40,8 @@ public void methodAdvice(MethodTransformer transformer) {
4040
private static final class Construct {
4141
@Advice.OnMethodExit(suppress = Throwable.class)
4242
public static void exit(@Advice.This ContextMap contextMap) {
43+
// Capture an active span on ST context copy to support versions prior to 0.42.56 that did not
44+
// have captureContext
4345
InstrumentationContext.get(ContextMap.class, AgentSpan.class)
4446
.put(contextMap, AgentTracer.activeSpan());
4547
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datadog.trace.instrumentation.servicetalk;
1+
package datadog.trace.instrumentation.servicetalk0_42_0;
22

33
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.namedOneOf;
44

@@ -13,7 +13,7 @@
1313
import net.bytebuddy.asm.Advice;
1414

1515
@AutoService(InstrumenterModule.class)
16-
public class ContextPreservingInstrumentation extends AbstractAsyncContextInstrumentation
16+
public class ContextPreservingInstrumentation extends ServiceTalkInstrumentation
1717
implements Instrumenter.ForKnownTypes, Instrumenter.HasMethodAdvice {
1818

1919
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package datadog.trace.instrumentation.servicetalk0_42_0;
2+
3+
import datadog.trace.agent.tooling.InstrumenterModule;
4+
import datadog.trace.agent.tooling.muzzle.Reference;
5+
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
6+
import java.util.Collections;
7+
import java.util.Map;
8+
9+
public abstract class ServiceTalkInstrumentation extends InstrumenterModule.Tracing {
10+
11+
public ServiceTalkInstrumentation() {
12+
super("servicetalk", "servicetalk-concurrent");
13+
}
14+
15+
@Override
16+
public Map<String, String> contextStore() {
17+
return Collections.singletonMap(
18+
"io.servicetalk.context.api.ContextMap", AgentSpan.class.getName());
19+
}
20+
21+
@Override
22+
public Reference[] additionalMuzzleReferences() {
23+
return new Reference[] {
24+
// This check prevents older instrumentation from being applied to ServiceTalk v0.42.56+
25+
new Reference.Builder("io.servicetalk.concurrent.api.DelegatingExecutor")
26+
// Removed in v0.42.56
27+
.withField(new String[0], 0, "delegate", "Lio/servicetalk/concurrent/api/Executor;")
28+
.build(),
29+
};
30+
}
31+
}

dd-java-agent/instrumentation/servicetalk/src/test/groovy/ContextPreservingInstrumentationTest.groovy renamed to dd-java-agent/instrumentation/servicetalk/servicetalk-0.42.0/src/test/groovy/ContextPreservingInstrumentationTest.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope
33
import datadog.trace.bootstrap.instrumentation.api.AgentTracer
44
import io.servicetalk.concurrent.api.AsyncContext
55
import io.servicetalk.context.api.ContextMap
6-
76
import java.util.concurrent.ExecutorService
87
import java.util.concurrent.Executors
98

@@ -150,7 +149,7 @@ class ContextPreservingInstrumentationTest extends AgentTestRunner {
150149
}
151150
}
152151

153-
private childSpan() {
152+
private static childSpan() {
154153
AgentTracer.startSpan("test", "child").finish()
155154
}
156155
}

0 commit comments

Comments
 (0)