Skip to content

Commit 43e4f33

Browse files
committed
Merge branch 'dougqh/crash-tracking-in-smoke-tests' of https://github.com/DataDog/dd-trace-java into dougqh/crash-tracking-in-smoke-tests
2 parents 5860ee9 + 9dcc2cc commit 43e4f33

File tree

244 files changed

+6180
-2641
lines changed

Some content is hidden

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

244 files changed

+6180
-2641
lines changed

.circleci/config.continue.yml.j2

Lines changed: 32 additions & 16 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 34 additions & 18 deletions
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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ _Recovery:_ Manually trigger the action again on the relevant tag.
5454
_Trigger:_ When creating a minor or major version tag.
5555

5656
_Actions:_
57+
5758
* Close the milestone related to the tag,
5859
* Create a new milestone by incrementing minor version.
5960

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

7879
_Action:_
80+
7981
* Find all issues related to the release by checking the related milestone,
8082
* Add a comment to let know the issue was addressed by the newly published release,
8183
* Close all those issues.
@@ -105,10 +107,13 @@ _Recovery:_ Manually trigger the action again.
105107

106108
_Trigger:_ When pushing commits to `master` or any pull request targeting `master`.
107109

108-
_Action:_
110+
_Action:_
111+
109112
* Run [DataDog Static Analysis](https://docs.datadoghq.com/static_analysis/) and upload result to DataDog Code Analysis,
110-
* 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`,
111-
* 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.
112117

113118
### comment-on-submodule-update [🔗](comment-on-submodule-update.yaml)
114119

.github/workflows/analyze-changes.yaml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ jobs:
1616
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # 4.1.6
1717
with:
1818
submodules: 'recursive'
19-
- name: Check code meets quality standards
20-
id: datadog-static-analysis
19+
# Run the static analysis on the staging environment to benefit from the new features not yet released
20+
- name: Check code meets quality standards (staging)
21+
id: datadog-static-analysis-staging
2122
uses: DataDog/datadog-static-analyzer-github-action@c74aff158c8cc1c3e285660713bcaa5f9c6d696e # v1
2223
with:
23-
dd_app_key: ${{ secrets.DD_APP_KEY }}
24-
dd_api_key: ${{ secrets.DD_API_KEY }}
25-
dd_site: datad0g.com
24+
dd_app_key: ${{ secrets.DATADOG_APP_KEY_STAGING }}
25+
dd_api_key: ${{ secrets.DATADOG_API_KEY_STAGING }}
26+
dd_site: "datad0g.com"
2627
dd_service: "dd-trace-java"
2728
dd_env: "ci"
2829
cpu_count: 2
@@ -77,11 +78,19 @@ jobs:
7778
# For now, CodeQL SARIF results are not supported by Datadog CI
7879
# - name: Upload results to Datadog CI Static Analysis
7980
# run: |
80-
# wget --no-verbose https://github.com/DataDog/datadog-ci/releases/download/v2.42.0/datadog-ci_linux-x64 -O datadog-ci
81+
# wget --no-verbose https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64 -O datadog-ci
8182
# chmod +x datadog-ci
8283
# ./datadog-ci sarif upload /home/runner/work/dd-trace-java/results/java.sarif --service dd-trace-java --env ci
8384
# env:
84-
# DD_API_KEY: ${{ secrets.DD_API_KEY }}
85+
# DD_API_KEY: ${{ secrets.DATADOG_APP_KEY_PROD }}
86+
# DD_SITE: datadoghq.com
87+
88+
# For now, CodeQL SARIF results are not supported by Datadog CI
89+
# - name: Upload results to Datadog Staging CI Static Analysis
90+
# run: |
91+
# ./datadog-ci sarif upload /home/runner/work/dd-trace-java/results/java.sarif --service dd-trace-java --env ci
92+
# env:
93+
# DD_API_KEY: ${{ secrets.DATADOG_API_KEY_STAGING }}
8594
# DD_SITE: datad0g.com
8695

8796
trivy:
@@ -152,9 +161,16 @@ jobs:
152161

153162
- name: Upload results to Datadog CI Static Analysis
154163
run: |
155-
wget --no-verbose https://github.com/DataDog/datadog-ci/releases/download/v2.42.0/datadog-ci_linux-x64 -O datadog-ci
164+
wget --no-verbose https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64 -O datadog-ci
156165
chmod +x datadog-ci
157166
./datadog-ci sarif upload trivy-results.sarif --service dd-trace-java --env ci
158167
env:
159-
DD_API_KEY: ${{ secrets.DD_API_KEY }}
168+
DD_API_KEY: ${{ secrets.DATADOG_API_KEY_PROD }}
169+
DD_SITE: datadoghq.com
170+
171+
- name: Upload results to Datadog Staging CI Static Analysis
172+
run: |
173+
./datadog-ci sarif upload trivy-results.sarif --service dd-trace-java --env ci
174+
env:
175+
DD_API_KEY: ${{ secrets.DATADOG_API_KEY_STAGING }}
160176
DD_SITE: datad0g.com

.github/workflows/check-pull-requests.yaml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Check pull requests
22
on:
33
pull_request:
4-
types: [opened, reopened, edited, labeled, unlabeled]
4+
types: [opened, edited, labeled, unlabeled]
55
branches:
66
- master
77
- release/v*
@@ -40,14 +40,36 @@ jobs:
4040
}
4141
// Add comment to the pull request
4242
if (labelsCheckFailed || titleCheckFailed) {
43-
await github.rest.issues.createComment({
44-
issue_number: context.payload.pull_request.number,
45-
owner: context.repo.owner,
46-
repo: context.repo.repo,
47-
body: 'Hi! 👋 Thanks for your pull request! 🎉\n\n' +
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' +
4846
'To help us review it, please make sure to:\n\n' +
4947
(labelsCheckFailed ? '* Add at least one type, and one component or instrumentation label to the pull request\n' : '') +
5048
(titleCheckFailed ? '* Remove the tag from the pull request title\n' : '') +
51-
'\nIf you need help, please check our [contributing guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md).'
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
5256
})
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+
}
5375
}

dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecoratorTest.groovy

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ class HttpServerDecoratorTest extends ServerDecoratorTest {
422422
def ig = new InstrumentationGateway()
423423
def ss = ig.getSubscriptionService(RequestContextSlot.APPSEC)
424424
def cbpAppSec = ig.getCallbackProvider(RequestContextSlot.APPSEC)
425-
def callbacks = new IGCallBacks(reqData)
425+
def data = reqData ? new Object() : null
426+
def callbacks = new IGCallBacks(data)
426427
if (reqStarted) {
427428
ss.registerCallback(EVENTS.requestStarted(), callbacks)
428429
}
@@ -434,7 +435,7 @@ class HttpServerDecoratorTest extends ServerDecoratorTest {
434435
}
435436
Map<String, String> headers = ["foo": "bar", "some": "thing", "another": "value"]
436437
def reqCtxt = Mock(RequestContext) {
437-
getData(RequestContextSlot.APPSEC) >> reqData
438+
getData(RequestContextSlot.APPSEC) >> data
438439
}
439440
def mSpan = Mock(AgentSpan) {
440441
getRequestContext() >> reqCtxt
@@ -461,13 +462,13 @@ class HttpServerDecoratorTest extends ServerDecoratorTest {
461462

462463
where:
463464
// spotless:off
464-
reqStarted | reqData | reqHeader | reqHeaderDone | reqStartedCount | reqHeaderCount | reqHeaderDoneCount
465-
false | null | false | false | 0 | 0 | 0
466-
false | new Object() | false | false | 0 | 0 | 0
467-
true | null | false | false | 1 | 0 | 0
468-
true | new Object() | false | false | 1 | 0 | 0
469-
true | new Object() | true | false | 1 | 3 | 0
470-
true | new Object() | true | true | 1 | 3 | 1
465+
reqStarted | reqData | reqHeader | reqHeaderDone | reqStartedCount | reqHeaderCount | reqHeaderDoneCount
466+
false | false | false | false | 0 | 0 | 0
467+
false | true | false | false | 0 | 0 | 0
468+
true | false | false | false | 1 | 0 | 0
469+
true | true | false | false | 1 | 0 | 0
470+
true | true | true | false | 1 | 3 | 0
471+
true | true | true | true | 1 | 3 | 1
471472
// spotless:on
472473
}
473474

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/CiVisibilityServices.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import datadog.trace.civisibility.git.GitClientGitInfoBuilder;
2424
import datadog.trace.civisibility.git.tree.GitClient;
2525
import datadog.trace.civisibility.ipc.SignalClient;
26-
import datadog.trace.civisibility.source.BestEffortMethodLinesResolver;
27-
import datadog.trace.civisibility.source.ByteCodeMethodLinesResolver;
28-
import datadog.trace.civisibility.source.CompilerAidedMethodLinesResolver;
29-
import datadog.trace.civisibility.source.MethodLinesResolver;
26+
import datadog.trace.civisibility.source.BestEffortLinesResolver;
27+
import datadog.trace.civisibility.source.ByteCodeLinesResolver;
28+
import datadog.trace.civisibility.source.CompilerAidedLinesResolver;
29+
import datadog.trace.civisibility.source.LinesResolver;
3030
import datadog.trace.civisibility.source.index.*;
3131
import java.lang.reflect.Type;
3232
import java.net.InetSocketAddress;
@@ -63,7 +63,7 @@ public class CiVisibilityServices {
6363
final CIProviderInfoFactory ciProviderInfoFactory;
6464
final GitClient.Factory gitClientFactory;
6565
final GitInfoProvider gitInfoProvider;
66-
final MethodLinesResolver methodLinesResolver;
66+
final LinesResolver linesResolver;
6767
final RepoIndexProvider.Factory repoIndexProviderFactory;
6868
@Nullable final SignalClient.Factory signalClientFactory;
6969

@@ -82,9 +82,8 @@ public class CiVisibilityServices {
8282

8383
CiEnvironment environment = buildCiEnvironment(config, sco);
8484
this.ciProviderInfoFactory = new CIProviderInfoFactory(config, environment);
85-
this.methodLinesResolver =
86-
new BestEffortMethodLinesResolver(
87-
new CompilerAidedMethodLinesResolver(), new ByteCodeMethodLinesResolver());
85+
this.linesResolver =
86+
new BestEffortLinesResolver(new CompilerAidedLinesResolver(), new ByteCodeLinesResolver());
8887

8988
this.gitInfoProvider = gitInfoProvider;
9089
gitInfoProvider.registerGitInfoBuilder(new CIProviderGitInfoBuilder(config, environment));

0 commit comments

Comments
 (0)