Skip to content

Commit 1b32ece

Browse files
authored
Merge branch 'master' into kr-igor/dsm-service-name-override
2 parents c2eb6cf + 2f767ab commit 1b32ece

File tree

262 files changed

+9123
-2093
lines changed

Some content is hidden

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

262 files changed

+9123
-2093
lines changed

.circleci/config.continue.yml.j2

+32-16
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ jobs:
816816
parameters:
817817
weblog-variant:
818818
type: string
819+
parallelism: 3
819820
steps:
820821
- setup_system_tests
821822
@@ -833,32 +834,38 @@ jobs:
833834
834835
- run:
835836
name: Run
836-
command: |
837-
cd system-tests
838-
DD_API_KEY=$SYSTEM_TESTS_DD_API_KEY ./run.sh
839-
840-
- run:
841-
name: Run APM E2E default tests
842837
# Stop the job after 5m to avoid excessive overhead. Will need adjustment as more tests are added.
843838
no_output_timeout: 5m
844839
command: |
845840
cd system-tests
846-
DD_SITE=datadoghq.com DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY ./run.sh APM_TRACING_E2E
841+
echo "
842+
DEFAULT
843+
APM_TRACING_E2E
844+
APM_TRACING_E2E_SINGLE_SPAN
845+
" | circleci tests split > scenarios.list
846+
for scenario in $(<scenarios.list); do
847+
if [[ $scenario =~ .*_E2E.* ]]; then
848+
export DD_SITE=datadoghq.com
849+
export DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY
850+
export DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY
851+
else
852+
export DD_API_KEY=$SYSTEM_TESTS_DD_API_KEY
853+
fi
854+
echo "Running scenario $scenario"
855+
./run.sh $scenario
856+
done
847857
848858
- run:
849-
name: Run APM E2E Single Span tests
850-
# Stop the job after 5m to avoid excessive overhead. Will need adjustment as more tests are added.
851-
no_output_timeout: 5m
859+
name: Collect artifacts
852860
command: |
861+
mkdir -p artifacts
853862
cd system-tests
854-
DD_SITE=datadoghq.com DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY ./run.sh APM_TRACING_E2E_SINGLE_SPAN
855-
856-
- run:
857-
name: Collect artifacts
858-
command: tar -cvzf logs_java_<< parameters.weblog-variant >>_dev.tar.gz -C system-tests logs logs_apm_tracing_e2e logs_apm_tracing_e2e_single_span
863+
for log_dir in logs*; do
864+
tar -cvzf ../artifacts/${log_dir}_<< parameters.weblog-variant >>.tar.gz $log_dir
865+
done
859866
860867
- store_artifacts:
861-
path: logs_java_<< parameters.weblog-variant >>_dev.tar.gz
868+
path: artifacts
862869
863870
integrations-system-tests:
864871
machine:
@@ -1363,6 +1370,14 @@ build_test_jobs: &build_test_jobs
13631370
stage: tracing
13641371
testJvm: "8"
13651372
1373+
- fan_in:
1374+
requires:
1375+
- test_8_inst_latest
1376+
- test_17_inst_latest
1377+
- test_21_inst_latest
1378+
name: test_inst_latest
1379+
stage: tracing
1380+
13661381
- agent_integration_tests:
13671382
requires:
13681383
- ok_to_test
@@ -1435,6 +1450,7 @@ build_test_jobs: &build_test_jobs
14351450
{% for jdk in all_jdks %}
14361451
- "test_{{ jdk }}"
14371452
{% endfor %}
1453+
- test_inst_latest
14381454
- muzzle
14391455
- profiling
14401456
- debugger

.circleci/render_config.py

+1-1
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.08"
31+
DOCKER_IMAGE_VERSION="v24.10"
3232

3333
# Get labels from pull requests to override some defaults for jobs to run.
3434
# `run-tests: all` will run all tests.

.circleci/upload_ciapp.sh

+34-18
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,42 @@
11
#!/usr/bin/env bash
22
SERVICE_NAME="dd-trace-java"
3+
PIPELINE_STAGE=$1
4+
TEST_JVM=$2
35

46
# 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
5-
java_home="JAVA_$2_HOME"
6-
java_bin="${!java_home}/bin/java"
7-
if [ ! -x $java_bin ]; then
8-
java_bin=$(which java)
7+
JAVA_HOME="JAVA_${TEST_JVM}_HOME"
8+
JAVA_BIN="${!JAVA_HOME}/bin/java"
9+
if [ ! -x "$JAVA_BIN" ]; then
10+
JAVA_BIN=$(which java)
911
fi
1012

11-
java_props=$($java_bin -XshowSettings:properties -version 2>&1)
12-
java_prop () {
13-
echo "$(echo "$java_props" | grep $1 | head -n1 | cut -d'=' -f2 | xargs)"
13+
# Extract Java properties from the JVM used to run the tests
14+
JAVA_PROPS=$($JAVA_BIN -XshowSettings:properties -version 2>&1)
15+
java_prop() {
16+
local PROP_NAME=$1
17+
echo "$JAVA_PROPS" | grep "$PROP_NAME" | head -n1 | cut -d'=' -f2 | xargs
1418
}
1519

16-
# 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
17-
datadog-ci junit upload --service $SERVICE_NAME \
18-
--logs \
19-
--tags "test.traits:{\"marker\":[\"$1\"]}" \
20-
--tags "runtime.name:$(java_prop java.runtime.name)" \
21-
--tags "runtime.vendor:$(java_prop java.vendor)" \
22-
--tags "runtime.version:$(java_prop java.version)" \
23-
--tags "os.architecture:$(java_prop os.arch)" \
24-
--tags "os.platform:$(java_prop os.name)" \
25-
--tags "os.version:$(java_prop os.version)" \
26-
./results
20+
# Upload test results to CI Visibility
21+
junit_upload() {
22+
# 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
23+
DD_API_KEY=$1 \
24+
datadog-ci junit upload --service $SERVICE_NAME \
25+
--logs \
26+
--tags "test.traits:{\"marker\":[\"$PIPELINE_STAGE\"]}" \
27+
--tags "runtime.name:$(java_prop java.runtime.name)" \
28+
--tags "runtime.vendor:$(java_prop java.vendor)" \
29+
--tags "runtime.version:$(java_prop java.version)" \
30+
--tags "os.architecture:$(java_prop os.arch)" \
31+
--tags "os.platform:$(java_prop os.name)" \
32+
--tags "os.version:$(java_prop os.version)" \
33+
./results
34+
}
35+
36+
# Make sure we do not use DATADOG_API_KEY from the environment
37+
unset DATADOG_API_KEY
38+
39+
# Upload test results to production environment like all other CI jobs
40+
junit_upload "$DATADOG_API_KEY_PROD"
41+
# And also upload to staging environment to benefit from the new features not yet released
42+
junit_upload "$DATADOG_API_KEY_DDSTAGING"

.github/workflows/README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ _Action:_ Append the new release to the Cloud Foundry repository.
2020

2121
_Recovery:_ Manually edit and push the `index.yml` file from [the cloudfoundry branch](https://github.com/DataDog/dd-trace-java/tree/cloudfoundry).
2222

23+
### check-pull-requests [🔗](check-pull-requests.yaml)
24+
25+
_Trigger:_ When creating or updating a pull request.
26+
27+
_Action:_ Check the pull request complies with [the contribution guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md).
28+
29+
_Recovery:_ Manually verify the guideline compliance.
30+
2331
### create-next-milestone [🔗](create-next-milestone.yaml)
2432

2533
_Trigger:_ When closing a milestone.
@@ -46,6 +54,7 @@ _Recovery:_ Manually trigger the action again on the relevant tag.
4654
_Trigger:_ When creating a minor or major version tag.
4755

4856
_Actions:_
57+
4958
* Close the milestone related to the tag,
5059
* Create a new milestone by incrementing minor version.
5160

@@ -68,6 +77,7 @@ _Notes:_ _Download releases_ are special GitHub releases with fixed URL and tags
6877
_Trigger:_ When a release is published. Releases of type `prereleased` should skip this.
6978

7079
_Action:_
80+
7181
* Find all issues related to the release by checking the related milestone,
7282
* Add a comment to let know the issue was addressed by the newly published release,
7383
* Close all those issues.
@@ -97,10 +107,13 @@ _Recovery:_ Manually trigger the action again.
97107

98108
_Trigger:_ When pushing commits to `master` or any pull request targeting `master`.
99109

100-
_Action:_
110+
_Action:_
111+
101112
* Run [DataDog Static Analysis](https://docs.datadoghq.com/static_analysis/) and upload result to DataDog Code Analysis,
102-
* Run [GitHub CodeQL](https://codeql.github.com/) action, upload result to GitHub security tab and DataDog Code Analysis -- do not apply to pull request, only when pushing to `master`,
103-
* Run [Trivy security scanner](https://github.com/aquasecurity/trivy) on built artifacts and upload result to GitHub security tab.
113+
* Run [GitHub CodeQL](https://codeql.github.com/) action, upload result to GitHub security tab -- do not apply to pull request, only when pushing to `master`,
114+
* Run [Trivy security scanner](https://github.com/aquasecurity/trivy) on built artifacts and upload result to GitHub security tab and Datadog Code Analysis.
115+
116+
_Notes:_ Results are sent on both production and staging environments.
104117

105118
### comment-on-submodule-update [🔗](comment-on-submodule-update.yaml)
106119

.github/workflows/analyze-changes.yaml

+38-8
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@ jobs:
1616
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # 4.1.6
1717
with:
1818
submodules: 'recursive'
19-
- name: Check code meets quality standards
19+
- name: Check code meets quality standards (production)
2020
id: datadog-static-analysis
2121
uses: DataDog/datadog-static-analyzer-github-action@c74aff158c8cc1c3e285660713bcaa5f9c6d696e # v1
2222
with:
23-
dd_app_key: ${{ secrets.DD_APP_KEY }}
24-
dd_api_key: ${{ secrets.DD_API_KEY }}
25-
dd_site: datad0g.com
23+
dd_app_key: ${{ secrets.DATADOG_APP_KEY_PROD }}
24+
dd_api_key: ${{ secrets.DATADOG_API_KEY_PROD }}
25+
dd_site: "datadoghq.com"
26+
dd_service: "dd-trace-java"
27+
dd_env: "ci"
28+
cpu_count: 2
29+
enable_performance_statistics: false
30+
# Also run the static analysis on the staging environment to benefit from the new features not yet released
31+
- name: Check code meets quality standards (staging)
32+
id: datadog-static-analysis-staging
33+
uses: DataDog/datadog-static-analyzer-github-action@c74aff158c8cc1c3e285660713bcaa5f9c6d696e # v1
34+
with:
35+
dd_app_key: ${{ secrets.DATADOG_APP_KEY_STAGING }}
36+
dd_api_key: ${{ secrets.DATADOG_API_KEY_STAGING }}
37+
dd_site: "datad0g.com"
2638
dd_service: "dd-trace-java"
2739
dd_env: "ci"
2840
cpu_count: 2
@@ -77,11 +89,19 @@ jobs:
7789
# For now, CodeQL SARIF results are not supported by Datadog CI
7890
# - name: Upload results to Datadog CI Static Analysis
7991
# run: |
80-
# wget --no-verbose https://github.com/DataDog/datadog-ci/releases/download/v2.42.0/datadog-ci_linux-x64 -O datadog-ci
92+
# wget --no-verbose https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64 -O datadog-ci
8193
# chmod +x datadog-ci
8294
# ./datadog-ci sarif upload /home/runner/work/dd-trace-java/results/java.sarif --service dd-trace-java --env ci
8395
# env:
84-
# DD_API_KEY: ${{ secrets.DD_API_KEY }}
96+
# DD_API_KEY: ${{ secrets.DATADOG_APP_KEY_PROD }}
97+
# DD_SITE: datadoghq.com
98+
99+
# For now, CodeQL SARIF results are not supported by Datadog CI
100+
# - name: Upload results to Datadog Staging CI Static Analysis
101+
# run: |
102+
# ./datadog-ci sarif upload /home/runner/work/dd-trace-java/results/java.sarif --service dd-trace-java --env ci
103+
# env:
104+
# DD_API_KEY: ${{ secrets.DATADOG_API_KEY_STAGING }}
85105
# DD_SITE: datad0g.com
86106

87107
trivy:
@@ -140,6 +160,9 @@ jobs:
140160
output: 'trivy-results.sarif'
141161
severity: 'CRITICAL,HIGH'
142162
limit-severities-for-sarif: true
163+
env:
164+
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
165+
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
143166

144167
- name: Upload Trivy scan results to GitHub Security tab
145168
uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
@@ -149,9 +172,16 @@ jobs:
149172

150173
- name: Upload results to Datadog CI Static Analysis
151174
run: |
152-
wget --no-verbose https://github.com/DataDog/datadog-ci/releases/download/v2.42.0/datadog-ci_linux-x64 -O datadog-ci
175+
wget --no-verbose https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64 -O datadog-ci
153176
chmod +x datadog-ci
154177
./datadog-ci sarif upload trivy-results.sarif --service dd-trace-java --env ci
155178
env:
156-
DD_API_KEY: ${{ secrets.DD_API_KEY }}
179+
DD_API_KEY: ${{ secrets.DATADOG_API_KEY_PROD }}
180+
DD_SITE: datadoghq.com
181+
182+
- name: Upload results to Datadog Staging CI Static Analysis
183+
run: |
184+
./datadog-ci sarif upload trivy-results.sarif --service dd-trace-java --env ci
185+
env:
186+
DD_API_KEY: ${{ secrets.DATADOG_API_KEY_STAGING }}
157187
DD_SITE: datad0g.com
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Check pull requests
2+
on:
3+
pull_request:
4+
types: [opened, edited, labeled, unlabeled]
5+
branches:
6+
- master
7+
- release/v*
8+
jobs:
9+
check_pull_requests:
10+
name: Check pull requests
11+
permissions:
12+
issues: write # Required to create a comment on the pull request
13+
pull-requests: write # Required to create a comment on the pull request
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check pull requests
17+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # 7.0.1
18+
with:
19+
github-token: ${{secrets.GITHUB_TOKEN}}
20+
script: |
21+
// Skip draft pull requests
22+
if (context.payload.pull_request.draft) {
23+
return
24+
}
25+
// Check at least one type and (component or instrumentation) label is set
26+
const labels = context.payload.pull_request.labels.map(label => label.name)
27+
const ignoreReleaseNotes = labels.filter(label => label == 'tag: no release notes').length > 0
28+
const hasTypeLabel = labels.filter(label => label.startsWith('type:')).length > 0
29+
const hasComponentLabel = labels.filter(label => label.startsWith('comp:')).length > 0
30+
const hasInstrumentationLabel = labels.filter(label => label.startsWith('instr:')).length > 0
31+
const labelsCheckFailed = !ignoreReleaseNotes && (!hasTypeLabel || (!hasComponentLabel && !hasInstrumentationLabel));
32+
if (labelsCheckFailed) {
33+
core.setFailed('Please add at least one type, and one component or instrumentation label to the pull request.')
34+
}
35+
// Check title does not contain tag
36+
const title = context.payload.pull_request.title
37+
const titleCheckFailed = title.match(/\[.*\]/)
38+
if (titleCheckFailed) {
39+
core.setFailed('Please remove the tag from the pull request title.')
40+
}
41+
// Add comment to the pull request
42+
if (labelsCheckFailed || titleCheckFailed) {
43+
// Define comment body
44+
const commentMarker = '<!-- dd-trace-java-check-pull-requests-workflow -->'
45+
const commentBody = 'Hi! 👋 Thanks for your pull request! 🎉\n\n' +
46+
'To help us review it, please make sure to:\n\n' +
47+
(labelsCheckFailed ? '* Add at least one type, and one component or instrumentation label to the pull request\n' : '') +
48+
(titleCheckFailed ? '* Remove the tag from the pull request title\n' : '') +
49+
'\nIf you need help, please check our [contributing guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md).' +
50+
'\n\n' + commentMarker
51+
// Look for previous comment
52+
const comments = await github.rest.issues.listComments({
53+
issue_number: context.payload.pull_request.number,
54+
owner: context.repo.owner,
55+
repo: context.repo.repo
56+
})
57+
const previousComment = comments.data.find(comment => comment.body.includes(commentMarker))
58+
if (previousComment) {
59+
// Update previous comment
60+
await github.rest.issues.updateComment({
61+
comment_id: previousComment.id,
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
body: commentBody
65+
})
66+
} else {
67+
// Create new comment
68+
await github.rest.issues.createComment({
69+
issue_number: context.payload.pull_request.number,
70+
owner: context.repo.owner,
71+
repo: context.repo.repo,
72+
body: commentBody
73+
})
74+
}
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": true,
5+
"labels": [],
6+
"title": "Adding some new features"
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": false,
5+
"labels": [
6+
{
7+
"name": "comp: api"
8+
}
9+
],
10+
"title": "Adding some new features"
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": false,
5+
"labels": [
6+
{
7+
"name": "tag: no release notes"
8+
}
9+
],
10+
"title": "Adding some new features"
11+
}
12+
}

0 commit comments

Comments
 (0)