Skip to content

Commit 4a06b50

Browse files
authored
Merge branch 'master' into kr-igor/kafka-lag-spark-streaming
2 parents e01394f + 62eb0c2 commit 4a06b50

File tree

115 files changed

+3323
-328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+3323
-328
lines changed

.circleci/collect_results.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@ shopt -s globstar
1010
TEST_RESULTS_DIR=./results
1111
mkdir -p $TEST_RESULTS_DIR >/dev/null 2>&1
1212

13-
echo "saving test results"
1413
mkdir -p $TEST_RESULTS_DIR
15-
find workspace/**/build/test-results -name \*.xml -exec sh -c '
14+
15+
mkdir -p workspace
16+
mapfile -t test_result_dirs < <(find workspace -name test-results -type d)
17+
18+
if [[ ${#test_result_dirs[@]} -eq 0 ]]; then
19+
echo "No test results found"
20+
exit 0
21+
fi
22+
23+
echo "saving test results"
24+
find "${test_result_dirs[@]}" -name \*.xml -exec sh -c '
1625
file=$(echo "$0" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
1726
cp "$0" "$1/$file"' {} $TEST_RESULTS_DIR \;

.circleci/config.continue.yml.j2

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ system_test_matrix: &system_test_matrix
3232

3333
agent_integration_tests_modules: &agent_integration_tests_modules "dd-trace-core|communication|internal-api|utils"
3434
core_modules: &core_modules "dd-java-agent|dd-trace-core|communication|internal-api|telemetry|utils|dd-java-agent/agent-bootstrap|dd-java-agent/agent-installer|dd-java-agent/agent-tooling|dd-java-agent/agent-builder|dd-java-agent/appsec|dd-java-agent/agent-crashtracking|dd-trace-api|dd-trace-ot"
35-
instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation|dd-java-agent/agent-tooling|dd-java-agent/agent-installer|dd-java-agent/agent-builder|dd-java-agent/agent-bootstrap|dd-java-agent/appsec|dd-java-agent/testing|dd-trace-core|dd-trace-api|internal-api|communication"
35+
instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation|dd-java-agent/agent-tooling|dd-java-agent/agent-iast|dd-java-agent/agent-installer|dd-java-agent/agent-builder|dd-java-agent/agent-bootstrap|dd-java-agent/appsec|dd-java-agent/testing|dd-trace-core|dd-trace-api|internal-api|communication"
3636
debugger_modules: &debugger_modules "dd-java-agent/agent-debugger|dd-java-agent/agent-bootstrap|dd-java-agent/agent-builder|internal-api|communication|dd-trace-core"
3737
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"
3838

39-
default_system_tests_commit: &default_system_tests_commit 06cbfad5f9facbc6e258d9c8208c466cd46efeea
39+
default_system_tests_commit: &default_system_tests_commit 20b61e9be1e8c922804f8e5ddc80ba4a1f4cdd5b
4040

4141
parameters:
4242
nightly:
@@ -99,6 +99,11 @@ commands:
9999
setup_code:
100100
steps:
101101
- checkout
102+
{% if use_git_changes %}
103+
- run:
104+
name: Fetch base branch
105+
command: git fetch origin {{ pr_base_ref }}
106+
{% endif %}
102107
- run:
103108
name: Checkout merge commit
104109
command: .circleci/checkout_merge_commit.sh
@@ -312,6 +317,9 @@ jobs:
312317
./gradlew clean
313318
<< parameters.gradleTarget >>
314319
-PskipTests
320+
{% if use_git_changes %}
321+
-PgitBaseRef=origin/{{ pr_base_ref }}
322+
{% endif %}
315323
<< pipeline.parameters.gradle_flags >>
316324
--max-workers=8
317325
--rerun-tasks
@@ -411,6 +419,9 @@ jobs:
411419
./gradlew
412420
<< parameters.gradleTarget >>
413421
-PskipTests
422+
{% if use_git_changes %}
423+
-PgitBaseRef=origin/{{ pr_base_ref }}
424+
{% endif %}
414425
-PrunBuildSrcTests
415426
-PtaskPartitionCount=${CIRCLE_NODE_TOTAL} -PtaskPartition=${CIRCLE_NODE_INDEX}
416427
<< pipeline.parameters.gradle_flags >>
@@ -556,6 +567,9 @@ jobs:
556567
./gradlew
557568
<< parameters.gradleTarget >>
558569
<< parameters.gradleParameters >>
570+
{% if use_git_changes %}
571+
-PgitBaseRef=origin/{{ pr_base_ref }}
572+
{% endif %}
559573
-PtaskPartitionCount=${CIRCLE_NODE_TOTAL} -PtaskPartition=${CIRCLE_NODE_INDEX}
560574
<<# parameters.testJvm >>-PtestJvm=<< parameters.testJvm >><</ parameters.testJvm >>
561575
<< pipeline.parameters.gradle_flags >>
@@ -916,7 +930,7 @@ jobs:
916930
parametric-tests:
917931
machine:
918932
image: ubuntu-2404:current
919-
resource_class: large
933+
resource_class: xlarge
920934
steps:
921935
- setup_system_tests
922936
@@ -933,6 +947,7 @@ jobs:
933947
name: Build runner
934948
command: |
935949
cd system-tests
950+
export TEST_LIBRARY=java
936951
./build.sh -i runner
937952
938953
- run:
@@ -941,12 +956,12 @@ jobs:
941956
set -e
942957
cd system-tests
943958
export TEST_LIBRARY=java
944-
export PYTEST_WORKER_COUNT=8
959+
export PYTEST_XDIST_AUTO_NUM_WORKERS=6
945960
set +e
946961
RUN_ATTEMPTS=1
947962
while [ $RUN_ATTEMPTS -le 3 ]; do
948963
echo "Running parametric test attempt $RUN_ATTEMPTS"
949-
timeout 780s ./run.sh PARAMETRIC --log-cli-level=DEBUG --durations=30 -vv
964+
timeout 12m ./run.sh PARAMETRIC --log-cli-level=DEBUG --durations=30 -vv
950965
status=$?
951966
#timneout returns 124 if it times out
952967
#if the return code is not 124, then we exit with the status

.circleci/render_config.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929
# Version to use for all the base Docker images, see
3030
# https://github.com/DataDog/dd-trace-java-docker-build/pkgs/container/dd-trace-java-docker-build
31-
DOCKER_IMAGE_VERSION="v24.04"
31+
DOCKER_IMAGE_VERSION="v24.08"
3232

3333
# Get labels from pull requests to override some defaults for jobs to run.
3434
# `run-tests: all` will run all tests.
@@ -52,7 +52,7 @@
5252
)
5353
resp.raise_for_status()
5454
except Exception as e:
55-
print(f"Request filed: {e}")
55+
print(f"Request failed: {e}")
5656
time.sleep(1)
5757
continue
5858
data = resp.json()
@@ -63,12 +63,18 @@
6363
labels = {
6464
l.replace("run-tests: ", "") for l in labels if l.startswith("run-tests: ")
6565
}
66+
# get the base reference (e.g. `master`), commit hash is also available at the `sha` field.
67+
pr_base_ref = data.get("base", {}).get("ref")
6668
else:
6769
labels = set()
70+
pr_base_ref = ""
6871

6972

7073
branch = os.environ.get("CIRCLE_BRANCH", "")
71-
if branch == "master" or branch.startswith("release/v") or "all" in labels:
74+
run_all = "all" in labels
75+
is_master_or_release = branch == "master" or branch.startswith("release/v")
76+
77+
if is_master_or_release or run_all:
7278
all_jdks = ALWAYS_ON_JDKS | MASTER_ONLY_JDKS
7379
else:
7480
all_jdks = ALWAYS_ON_JDKS | (MASTER_ONLY_JDKS & labels)
@@ -83,6 +89,9 @@
8389
is_weekly = os.environ.get("CIRCLE_IS_WEEKLY", "false") == "true"
8490
is_regular = not is_nightly and not is_weekly
8591

92+
# Use git changes detection on PRs
93+
use_git_changes = not run_all and not is_master_or_release and is_regular
94+
8695
vars = {
8796
"is_nightly": is_nightly,
8897
"is_weekly": is_weekly,
@@ -92,12 +101,14 @@
92101
"nocov_jdks": nocov_jdks,
93102
"flaky": branch == "master" or "flaky" in labels or "all" in labels,
94103
"docker_image_prefix": "" if is_nightly else f"{DOCKER_IMAGE_VERSION}-",
104+
"use_git_changes": use_git_changes,
105+
"pr_base_ref": pr_base_ref,
95106
}
96107

97108
print(f"Variables for this build: {vars}")
98109

99110
loader = jinja2.FileSystemLoader(searchpath=SCRIPT_DIR)
100-
env = jinja2.Environment(loader=loader)
111+
env = jinja2.Environment(loader=loader, trim_blocks=True)
101112
tpl = env.get_template(TPL_FILENAME)
102113
out = tpl.render(**vars)
103114

.circleci/upload_ciapp.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ java_prop () {
1515

1616
# based on tracer implementation: https://github.com/DataDog/dd-trace-java/blob/master/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/TestDecorator.java#L55-L77
1717
datadog-ci junit upload --service $SERVICE_NAME \
18+
--logs \
1819
--tags "test.traits:{\"marker\":[\"$1\"]}" \
1920
--tags "runtime.name:$(java_prop java.runtime.name)" \
2021
--tags "runtime.vendor:$(java_prop java.vendor)" \

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ dd-java-agent/agent-iast/ @DataDog/asm-java
4343
dd-java-agent/instrumentation/*iast* @DataDog/asm-java
4444
dd-java-agent/instrumentation/*appsec* @DataDog/asm-java
4545
dd-java-agent/instrumentation/json/ @DataDog/asm-java
46+
dd-java-agent/instrumentation/snakeyaml/ @DataDog/asm-java
4647
dd-smoke-tests/iast-util/ @DataDog/asm-java
4748
dd-smoke-tests/spring-security/ @DataDog/asm-java
4849
dd-java-agent/instrumentation/commons-fileupload/ @DataDog/asm-java
@@ -54,4 +55,4 @@ dd-java-agent/instrumentation/spring-security-5/ @DataDog/asm-java
5455

5556
# @DataDog/data-jobs-monitoring
5657
dd-java-agent/instrumentation/spark/ @DataDog/data-jobs-monitoring
57-
dd-java-agent/instrumentation/spark-executor/ @DataDog/data-jobs-monitoring
58+
dd-java-agent/instrumentation/spark-executor/ @DataDog/data-jobs-monitoring

.github/workflows/add-release-to-cloudfoundry.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
MAX_TRIES=60 # Wait up to 30 minutes
2727
DELAY=30
2828
while [ $TRY -lt $MAX_TRIES ]; do
29-
if curl -s -I ${{ steps.get-release-url.outputs.URL }} | grep -q "200 OK"; then
29+
if curl -s -I ${{ steps.get-release-url.outputs.URL }} | grep -q "^HTTP/.* 200"; then
3030
break
3131
fi
3232
echo "Waiting for the release to be available..."

build.gradle

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -151,57 +151,4 @@ allprojects {
151151
}
152152
}
153153

154-
allprojects { project ->
155-
project.ext {
156-
activePartition = true
157-
}
158-
final boolean shouldUseTaskPartitions = project.rootProject.hasProperty("taskPartitionCount") && project.rootProject.hasProperty("taskPartition")
159-
if (shouldUseTaskPartitions) {
160-
final int taskPartitionCount = project.rootProject.property("taskPartitionCount") as int
161-
final int taskPartition = project.rootProject.property("taskPartition") as int
162-
final currentTaskPartition = Math.abs(project.path.hashCode() % taskPartitionCount)
163-
project.setProperty("activePartition", currentTaskPartition == taskPartition)
164-
}
165-
}
166-
167-
168-
def testAggregate(String baseTaskName, includePrefixes, excludePrefixes, boolean forceCoverage = false) {
169-
def createRootTask = { rootTaskName, subProjTaskName ->
170-
def coverage = forceCoverage || rootProject.hasProperty("checkCoverage")
171-
tasks.register(rootTaskName) { aggTest ->
172-
subprojects { subproject ->
173-
if (subproject.property("activePartition") && includePrefixes.any { subproject.path.startsWith(it) } && !excludePrefixes.any { subproject.path.startsWith(it) }) {
174-
def testTask = subproject.tasks.findByName(subProjTaskName)
175-
if (testTask != null) {
176-
aggTest.dependsOn(testTask)
177-
}
178-
if (coverage) {
179-
def coverageTask = subproject.tasks.findByName("jacocoTestReport")
180-
if (coverageTask != null) {
181-
aggTest.dependsOn(coverageTask)
182-
}
183-
coverageTask = subproject.tasks.findByName("jacocoTestCoverageVerification")
184-
if (coverageTask != null) {
185-
aggTest.dependsOn(coverageTask)
186-
}
187-
}
188-
}
189-
}
190-
}
191-
}
192-
193-
createRootTask "${baseTaskName}Test", 'allTests'
194-
createRootTask "${baseTaskName}LatestDepTest", 'allLatestDepTests'
195-
createRootTask "${baseTaskName}Check", 'check'
196-
}
197-
198-
testAggregate("smoke", [":dd-smoke-tests"], [])
199-
testAggregate("instrumentation", [":dd-java-agent:instrumentation"], [])
200-
testAggregate("profiling", [":dd-java-agent:agent-profiling"], [])
201-
testAggregate("debugger", [":dd-java-agent:agent-debugger"], [], true)
202-
testAggregate("base", [":"], [
203-
":dd-java-agent:instrumentation",
204-
":dd-smoke-tests",
205-
":dd-java-agent:agent-profiling",
206-
":dd-java-agent:agent-debugger"
207-
])
154+
apply from: "$rootDir/gradle/ci_jobs.gradle"

buildSrc/call-site-instrumentation-plugin/src/main/java/datadog/trace/plugin/csi/impl/AdviceGeneratorImpl.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import datadog.trace.plugin.csi.util.ErrorCode;
5656
import datadog.trace.plugin.csi.util.MethodType;
5757
import java.io.File;
58+
import java.util.ArrayList;
5859
import java.util.Arrays;
5960
import java.util.List;
6061
import java.util.stream.Collectors;
@@ -156,9 +157,11 @@ private static ClassOrInterfaceDeclaration callSitesType(
156157
type.setModifier(PUBLIC, true);
157158
type.setName(getClassName(advice));
158159
type.addImplementedType(CALL_SITES_CLASS);
159-
if (!CALL_SITES_FQCN.equals(callSite.getSpi().getClassName())) {
160-
javaClass.addImport(callSite.getSpi().getClassName());
161-
type.addImplementedType(getClassName(callSite.getSpi(), false));
160+
for (final Type spi : callSite.getSpi()) {
161+
if (!CALL_SITES_FQCN.equals(spi.getClassName())) {
162+
javaClass.addImport(spi.getClassName());
163+
type.addImplementedType(getClassName(spi, false));
164+
}
162165
}
163166
javaClass.addType(type);
164167
return type;
@@ -168,9 +171,12 @@ private static void addAutoServiceAnnotation(
168171
final ClassOrInterfaceDeclaration javaClass, final CallSiteSpecification callSite) {
169172
final NormalAnnotationExpr autoService = new NormalAnnotationExpr();
170173
autoService.setName(AUTO_SERVICE_FQDN);
171-
autoService.addPair(
172-
"value",
173-
new ClassExpr(new ClassOrInterfaceType().setName(getClassName(callSite.getSpi(), false))));
174+
final Type[] spiTypes = callSite.getSpi();
175+
final List<Expression> spiExprs = new ArrayList<>(spiTypes.length);
176+
for (final Type spi : spiTypes) {
177+
spiExprs.add(new ClassExpr(new ClassOrInterfaceType().setName(getClassName(spi, false))));
178+
}
179+
autoService.addPair("value", new ArrayInitializerExpr().setValues(new NodeList<>(spiExprs)));
174180
javaClass.addAnnotation(autoService);
175181
}
176182

buildSrc/call-site-instrumentation-plugin/src/main/java/datadog/trace/plugin/csi/impl/AsmSpecificationBuilder.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private static class SpecificationVisitor extends ClassVisitor {
7676
private boolean isCallSite;
7777
private final List<AdviceSpecification> advices = new ArrayList<>();
7878
private final Set<Type> helpers = new HashSet<>();
79-
private Type spi;
79+
private final Set<Type> spi = new HashSet<>();
8080
private List<String> enabled = new ArrayList<>();
8181
private CallSiteSpecification result;
8282

@@ -101,16 +101,17 @@ public AnnotationVisitor visitAnnotation(final String descriptor, final boolean
101101
if (isCallSite) {
102102
helpers.add(clazz);
103103
return new AnnotationVisitor(ASM_API_VERSION) {
104-
@Override
105-
public void visit(final String key, final Object value) {
106-
if ("spi".equals(key)) {
107-
spi = (Type) value;
108-
}
109-
}
110104

111105
@Override
112106
public AnnotationVisitor visitArray(final String name) {
113-
if ("helpers".equals(name)) {
107+
if ("spi".equals(name)) {
108+
return new AnnotationVisitor(ASM_API_VERSION) {
109+
@Override
110+
public void visit(final String name, final Object value) {
111+
spi.add((Type) value);
112+
}
113+
};
114+
} else if ("helpers".equals(name)) {
114115
return new AnnotationVisitor(ASM_API_VERSION) {
115116
@Override
116117
public void visit(final String name, final Object value) {

buildSrc/call-site-instrumentation-plugin/src/main/java/datadog/trace/plugin/csi/impl/CallSiteSpecification.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ public class CallSiteSpecification implements Validatable {
3232

3333
private final Type clazz;
3434
private final List<AdviceSpecification> advices;
35-
private final Type spi;
35+
private final Type[] spi;
3636
private final Enabled enabled;
3737
private final Type[] helpers;
3838

3939
public CallSiteSpecification(
4040
@Nonnull final Type clazz,
4141
@Nonnull final List<AdviceSpecification> advices,
42-
@Nonnull final Type spi,
42+
@Nonnull final Set<Type> spi,
4343
@Nonnull final List<String> enabled,
4444
@Nonnull final Set<Type> helpers) {
4545
this.clazz = clazz;
4646
this.advices = advices;
47-
this.spi = spi;
47+
this.spi = spi.toArray(new Type[0]);
4848
this.enabled = enabled.isEmpty() ? null : new Enabled(enabled);
4949
this.helpers = helpers.toArray(new Type[0]);
5050
}
@@ -53,12 +53,14 @@ public CallSiteSpecification(
5353
public void validate(@Nonnull final ValidationContext context) {
5454
final TypeResolver typeResolver = context.getContextProperty(TYPE_RESOLVER);
5555
try {
56-
Class<?> spiClass = typeResolver.resolveType(spi);
57-
if (!spiClass.isInterface()) {
58-
context.addError(ErrorCode.CALL_SITE_SPI_SHOULD_BE_AN_INTERFACE, spiClass);
59-
} else {
60-
if (spiClass.getDeclaredMethods().length > 0) {
61-
context.addError(ErrorCode.CALL_SITE_SPI_SHOULD_BE_EMPTY, spiClass);
56+
for (Type spiType : spi) {
57+
Class<?> spiClass = typeResolver.resolveType(spiType);
58+
if (!spiClass.isInterface()) {
59+
context.addError(ErrorCode.CALL_SITE_SPI_SHOULD_BE_AN_INTERFACE, spiClass);
60+
} else {
61+
if (spiClass.getDeclaredMethods().length > 0) {
62+
context.addError(ErrorCode.CALL_SITE_SPI_SHOULD_BE_EMPTY, spiClass);
63+
}
6264
}
6365
}
6466
} catch (ResolutionException e) {
@@ -84,7 +86,7 @@ public Type getClazz() {
8486
return clazz;
8587
}
8688

87-
public Type getSpi() {
89+
public Type[] getSpi() {
8890
return spi;
8991
}
9092

0 commit comments

Comments
 (0)