Skip to content

Commit 01dccb0

Browse files
authored
Merge branch 'master' into dougqh/guardrails-telemetry
2 parents 651b125 + f6c87de commit 01dccb0

File tree

127 files changed

+3368
-527
lines changed

Some content is hidden

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

127 files changed

+3368
-527
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: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ 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

@@ -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 >>
@@ -1057,7 +1071,7 @@ build_test_jobs: &build_test_jobs
10571071
name: z_test_<< matrix.testJvm >>_base
10581072
triggeredBy: *core_modules
10591073
gradleTarget: ":baseTest"
1060-
gradleParameters: "-PskipFlakyTests -PskipInstTests -PskipSmokeTests -PskipProfilingTests -PskipDebuggerTests"
1074+
gradleParameters: "-PskipFlakyTests"
10611075
stage: core
10621076
cacheType: base
10631077
parallelism: 4
@@ -1070,8 +1084,8 @@ build_test_jobs: &build_test_jobs
10701084
- ok_to_test
10711085
name: z_test_8_base
10721086
triggeredBy: *core_modules
1073-
gradleTarget: :baseTest jacocoTestReport jacocoTestCoverageVerification
1074-
gradleParameters: "-PskipFlakyTests -PskipInstTests -PskipSmokeTests -PskipProfilingTests -PskipDebuggerTests"
1087+
gradleTarget: :baseTest
1088+
gradleParameters: "-PskipFlakyTests -PcheckCoverage"
10751089
stage: core
10761090
cacheType: base
10771091
parallelism: 4

.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/workflows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ _Action:_ Run GitHub CodeQL action, upload result to GitHub security tab and Dat
9898

9999
_Trigger:_ Every week or manually.
100100

101-
_Action:_ Update the Grade dependencies and their locking files.
101+
_Action:_ Create a PR updating the Grade dependencies and their locking files.
102102

103103
_Recovery:_ Manually trigger the action again.
104104

.github/workflows/add-milestone-to-pull-requests.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ jobs:
5757
return a.version.patch - b.version.patch
5858
})
5959
.pop()?.number
60-
} else if (base.startsWith('release/v')) {
61-
// Pick the milestone with the same title as the base branch
62-
const version = base.substring(9)
60+
} else if (base.startsWith('release/v') && base.endsWith('.x')) {
61+
// Extract the minor version related to the base branch (e.g. "release/v1.2.x" -> "1.2.")
62+
const version = base.substring(9, base.length - 1)
63+
// Pick the milestone with title matching the extracted version
6364
const versionMilestone = response.data
64-
.find(milestone => milestone.title == version)
65+
.find(milestone => milestone.title.startsWith(version))
6566
if (!versionMilestone) {
66-
core.setFailed(`Version milestone not found: ${version}`)
67+
core.setFailed(`Milestone not found for minor version: ${version}`)
6768
} else {
6869
milestoneNumber = versionMilestone.number
6970
}

.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..."

.github/workflows/update-gradle-dependencies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
GH_TOKEN: ${{ github.token }}
7171
run: |
7272
gh pr create --title "Update Gradle dependencies" \
73-
--body "This PR updates the Gradle dependencies. \n:warning: Don't forget to squash commits before merging :warning:" \
73+
--body "This PR updates the Gradle dependencies. ⚠️ Don't forget to squash commits before merging. ⚠️" \
7474
--base master \
7575
--head $BRANCH_NAME \
7676
--label "tag: dependencies" \

build.gradle

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -151,56 +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 coverage = false) {
169-
def createRootTask = { rootTaskName, subProjTaskName ->
170-
tasks.register(rootTaskName) { aggTest ->
171-
subprojects { subproject ->
172-
if (subproject.property("activePartition") && includePrefixes.any { subproject.path.startsWith(it) } && !excludePrefixes.any { subproject.path.startsWith(it) }) {
173-
def testTask = subproject.tasks.findByName(subProjTaskName)
174-
if (testTask != null) {
175-
aggTest.dependsOn(testTask)
176-
}
177-
if (coverage) {
178-
def coverageTask = subproject.tasks.findByName("jacocoTestReport")
179-
if (coverageTask != null) {
180-
aggTest.dependsOn(coverageTask)
181-
}
182-
coverageTask = subproject.tasks.findByName("jacocoTestCoverageVerification")
183-
if (coverageTask != null) {
184-
aggTest.dependsOn(coverageTask)
185-
}
186-
}
187-
}
188-
}
189-
}
190-
}
191-
192-
createRootTask "${baseTaskName}Test", 'allTests'
193-
createRootTask "${baseTaskName}LatestDepTest", 'allLatestDepTests'
194-
createRootTask "${baseTaskName}Check", 'check'
195-
}
196-
197-
testAggregate("smoke", [":dd-smoke-tests"], [])
198-
testAggregate("instrumentation", [":dd-java-agent:instrumentation"], [])
199-
testAggregate("profiling", [":dd-java-agent:agent-profiling"], [])
200-
testAggregate("debugger", [":dd-java-agent:agent-debugger"], [], true)
201-
testAggregate("base", [":"], [
202-
":dd-java-agent:instrumentation",
203-
":dd-smoke-tests",
204-
":dd-java-agent:agent-profiling",
205-
":dd-java-agent:agent-debugger"
206-
])
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

0 commit comments

Comments
 (0)