Skip to content

Commit a08d00e

Browse files
authored
Merge branch 'master' into dougqh/advice-annotation-checking
2 parents 1e6c3ca + 31bfaf7 commit a08d00e

File tree

140 files changed

+5300
-325
lines changed

Some content is hidden

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

140 files changed

+5300
-325
lines changed

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

.github/workflows/README.md

Lines changed: 8 additions & 0 deletions
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.

.github/workflows/analyze-changes.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ jobs:
140140
output: 'trivy-results.sarif'
141141
severity: 'CRITICAL,HIGH'
142142
limit-severities-for-sarif: true
143+
env:
144+
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
145+
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
143146

144147
- name: Upload Trivy scan results to GitHub Security tab
145148
uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
Lines changed: 75 additions & 0 deletions
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+
}
Lines changed: 8 additions & 0 deletions
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+
}
Lines changed: 12 additions & 0 deletions
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+
}
Lines changed: 12 additions & 0 deletions
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+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": false,
5+
"labels": [
6+
{
7+
"name": "comp: api"
8+
},
9+
{
10+
"name": "type: enhancement"
11+
}
12+
],
13+
"title": "[API] Adding some new features"
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": false,
5+
"labels": [
6+
{
7+
"name": "comp: api"
8+
},
9+
{
10+
"name": "type: enhancement"
11+
}
12+
],
13+
"title": "Adding some new features"
14+
}
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
source "$(dirname "$0")/../env.sh"
3+
testworkflow pull_request && \
4+
testworkflow pull_request draft && \
5+
testworkflow pull_request no-release-notes && \
6+
! testworkflow pull_request missing-label && \
7+
! testworkflow pull_request title-tag

.github/workflows/tests/env.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@
22

33
function testworkflow() {
44
local EVENT_TYPE=$1
5+
local SCENARIO=$2
56
# Get workflow name
67
local TEST_PATH
78
TEST_PATH=$(dirname "$(readlink -f "${BASH_SOURCE[1]}")")
89
local WORKFLOW_NAME
910
WORKFLOW_NAME=$(basename "$TEST_PATH")
1011
local WORKFLOW_FILE=.github/workflows/${WORKFLOW_NAME}.yaml
11-
local PAYLOAD_FILE=${TEST_PATH}/payload-${EVENT_TYPE//_/-}.json
12+
local PAYLOAD_FILE
13+
PAYLOAD_FILE=${TEST_PATH}/payload-${EVENT_TYPE//_/-}
14+
if [ "$SCENARIO" != "" ]; then
15+
PAYLOAD_FILE=${PAYLOAD_FILE}-${SCENARIO}
16+
fi
17+
PAYLOAD_FILE=${PAYLOAD_FILE}.json
1218
# Move to project root directory
1319
local FILE_PATH
1420
FILE_PATH=$(dirname "$0")
15-
cd "$FILE_PATH/../../../../" || exit 1
21+
pushd "$FILE_PATH/../../../../" || exit 1
1622
# Check if workflow file and payload file exist
1723
if [ ! -f "$WORKFLOW_FILE" ]; then
1824
echo "Workflow file not found: $WORKFLOW_FILE"
@@ -29,4 +35,10 @@ function testworkflow() {
2935
--container-architecture linux/amd64 \
3036
--secret GITHUB_TOKEN="$(gh auth token)" \
3137
--verbose
38+
# Capture the exit code
39+
local EXIT_CODE=$?
40+
# Move back to initial directory
41+
popd || exit 1
42+
# Return the test exit code
43+
return $EXIT_CODE
3244
}

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/coverage/percentage/JacocoCoverageCalculator.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.io.BufferedInputStream;
1717
import java.io.ByteArrayInputStream;
1818
import java.io.File;
19+
import java.io.FileOutputStream;
1920
import java.io.IOException;
2021
import java.io.InputStream;
2122
import java.nio.file.Files;
@@ -43,6 +44,7 @@
4344
import org.jacoco.report.IReportVisitor;
4445
import org.jacoco.report.InputStreamSourceFileLocator;
4546
import org.jacoco.report.html.HTMLFormatter;
47+
import org.jacoco.report.xml.XMLFormatter;
4648
import org.slf4j.Logger;
4749
import org.slf4j.LoggerFactory;
4850

@@ -290,12 +292,23 @@ private void dumpCoverageReport(IBundleCoverage coverageBundle, File reportFolde
290292
}
291293
try {
292294
final HTMLFormatter htmlFormatter = new HTMLFormatter();
293-
final IReportVisitor visitor =
295+
296+
final IReportVisitor htmlVisitor =
294297
htmlFormatter.createVisitor(new FileMultiReportOutput(reportFolder));
295-
visitor.visitInfo(Collections.emptyList(), Collections.emptyList());
296-
visitor.visitBundle(
298+
htmlVisitor.visitInfo(Collections.emptyList(), Collections.emptyList());
299+
htmlVisitor.visitBundle(
297300
coverageBundle, new RepoIndexFileLocator(repoIndexProvider.getIndex(), repoRoot));
298-
visitor.visitEnd();
301+
htmlVisitor.visitEnd();
302+
303+
File xmlReport = new File(reportFolder, "jacoco.xml");
304+
try (FileOutputStream xmlReportStream = new FileOutputStream(xmlReport)) {
305+
XMLFormatter xmlFormatter = new XMLFormatter();
306+
IReportVisitor xmlVisitor = xmlFormatter.createVisitor(xmlReportStream);
307+
xmlVisitor.visitInfo(Collections.emptyList(), Collections.emptyList());
308+
xmlVisitor.visitBundle(
309+
coverageBundle, new RepoIndexFileLocator(repoIndexProvider.getIndex(), repoRoot));
310+
xmlVisitor.visitEnd();
311+
}
299312
} catch (Exception e) {
300313
LOGGER.error("Error while creating report in {}", reportFolder, e);
301314
}

dd-java-agent/agent-crashtracking/src/main/java/com/datadog/crashtracking/CrashUploader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ private RequestBody makeTelemetryRequestBody(@Nonnull String content) throws IOE
293293
writer.name("message").value(crashLog.toJson());
294294
writer.name("level").value("ERROR");
295295
writer.name("tags").value("severity:crash");
296+
writer.name("is_sensitive").value(true);
296297
writer.endObject();
297298
writer.endArray();
298299
writer.name("application");

dd-java-agent/agent-crashtracking/src/main/java/com/datadog/crashtracking/parsers/HotspotCrashLogParser.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,8 @@ public CrashLog parse(String crashLog) {
188188
state = State.DONE;
189189
} else {
190190
// Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
191-
if (line.contains("libjvm.so") || line.contains("libjavaProfiler")) {
192-
message.append(line).append('\n');
193-
frames.add(parseLine(line));
194-
} else {
195-
message.append(line.charAt(0)).append(" [redacted]\n");
196-
frames.add(new StackFrame(null, 0, "[redacted]"));
197-
}
191+
message.append(line).append('\n');
192+
frames.add(parseLine(line));
198193
}
199194
break;
200195
case DONE:

dd-java-agent/agent-crashtracking/src/test/java/com/datadog/crashtracking/CrashUploaderTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public class CrashUploaderTest {
7777
@BeforeEach
7878
public void setup() throws IOException {
7979
server.start();
80+
System.out.println("Setting up test: " + server.getPort());
8081
url = server.url(URL_PATH);
8182

8283
when(config.getEnv()).thenReturn(ENV);
@@ -170,6 +171,7 @@ public void testTelemetryHappyPath(String log) throws Exception {
170171
// payload:
171172
assertEquals("ERROR", event.get("payload").get(0).get("level").asText());
172173

174+
assertTrue(event.get("payload").get(0).get("is_sensitive").asBoolean());
173175
// we need to sanitize the UIID which keeps on changing
174176
String message = event.get("payload").get(0).get("message").asText();
175177
CrashLog extracted = CrashLog.fromJson(message);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"error":{"is_crash":true,"kind":"SIGSEGV","message":"\n\nJRE version: OpenJDK Runtime Environment Temurin-22.0.1+8 (22.0.1+8) (build 22.0.1+8)\nJava VM: OpenJDK 64-Bit Server VM Temurin-22.0.1+8 (22.0.1+8, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)\nProblematic frame:\nC [libpthread.so.0+0x9cd5] __pthread_clockjoin_ex+0x255\n\nNative frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)\nC [redacted]\n","source_type":"crashtracking","stack":{"format":"CrashTrackerV1","frames":[{"function":"[redacted]","line":0}]}},"incomplete":false,"metadata":{"family":"java","library_name":"dd-trace-java","library_version":"1.40.0-SNAPSHOT~b4718bd887","tags":{}},"os_info":{"architecture":"aarch64","bitness":"64","os_type":"Mac OS X","version":{"Semantic":[14,6,1]}},"proc_info":{"pid":"576034"},"timestamp":"2024-09-20T13:19:06Z","uuid":"477a8d3f-d381-4352-a2a9-76eeefeef242","version_id":0}
1+
{"error":{"is_crash":true,"kind":"SIGSEGV","message":"\n\nJRE version: OpenJDK Runtime Environment Temurin-22.0.1+8 (22.0.1+8) (build 22.0.1+8)\nJava VM: OpenJDK 64-Bit Server VM Temurin-22.0.1+8 (22.0.1+8, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)\nProblematic frame:\nC [libpthread.so.0+0x9cd5] __pthread_clockjoin_ex+0x255\n\nNative frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)\nC [libpthread.so.0+0x9cd5] __pthread_clockjoin_ex+0x255\n","source_type":"crashtracking","stack":{"format":"CrashTrackerV1","frames":[{"function":"__pthread_clockjoin_ex","line":0}]}},"incomplete":false,"metadata":{"family":"java","library_name":"dd-trace-java","library_version":"1.42.0-SNAPSHOT~aa29078ace","tags":{}},"os_info":{"architecture":"aarch64","bitness":"64","os_type":"Mac OS X","version":{"Semantic":[14,7,0]}},"proc_info":{"pid":"576034"},"timestamp":"2024-09-20T13:19:06Z","uuid":"363ac4ba-c104-4c8f-9aaa-5870486a8926","version_id":0}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"error":{"is_crash":true,"kind":"INVALID","message":"\n\n fatal error: OutOfMemory encountered: Java heap space\nJRE version: OpenJDK Runtime Environment (Zulu 8.70.0.23-CA-macos-aarch64) (8.0_372-b07) (build 1.8.0_372-b07)\nJava VM: OpenJDK 64-Bit Server VM (25.372-b07 mixed mode bsd-aarch64 compressed oops)\n\nNative frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)\nV [redacted]\nV [redacted]\nV [redacted]\nV [redacted]\nV [redacted]\nV [redacted]\nj [redacted]\nv [redacted]\nV [redacted]\nV [redacted]\nV [redacted]\nC [redacted]\nC [redacted]\nC [redacted]\n","source_type":"crashtracking","stack":{"format":"CrashTrackerV1","frames":[{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0},{"function":"[redacted]","line":0}]}},"incomplete":false,"metadata":{"family":"java","library_name":"dd-trace-java","library_version":"1.40.0-SNAPSHOT~b4718bd887","tags":{}},"os_info":{"architecture":"aarch64","bitness":"64","os_type":"Mac OS X","version":{"Semantic":[14,6,1]}},"proc_info":{"pid":"96267"},"uuid":"9b651ca7-0671-4805-bd91-c83ba131ece9","version_id":0}
1+
{"error":{"is_crash":true,"kind":"INVALID","message":"\n\n fatal error: OutOfMemory encountered: Java heap space\nJRE version: OpenJDK Runtime Environment (Zulu 8.70.0.23-CA-macos-aarch64) (8.0_372-b07) (build 1.8.0_372-b07)\nJava VM: OpenJDK 64-Bit Server VM (25.372-b07 mixed mode bsd-aarch64 compressed oops)\n\nNative frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)\nV [libjvm.dylib+0x565d30] VMError::report_and_die()+0x468\nV [libjvm.dylib+0x1941a0] report_vm_error(char const*, int, char const*, char const*)+0x5c\nV [libjvm.dylib+0x1943d8] report_java_out_of_memory(char const*)+0xfc\nV [libjvm.dylib+0x70430] CollectedHeap::common_mem_allocate_noinit(KlassHandle, unsigned long, Thread*)+0x128\nV [libjvm.dylib+0x53eba8] TypeArrayKlass::allocate_common(int, bool, Thread*)+0xfc\nV [libjvm.dylib+0x285b6c] InterpreterRuntime::newarray(JavaThread*, BasicType, int)+0x48\nj datadog.smoketest.crashtracking.CrashtrackingTestApplication.main([Ljava/lang/String;)V+105\nv ~StubRoutines::call_stub\nV [libjvm.dylib+0x28f86c] JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*)+0x840\nV [libjvm.dylib+0x2d3b44] jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x294\nV [libjvm.dylib+0x2d7160] jni_CallStaticVoidMethod+0x188\nC [java+0x6404] JavaMain+0xa10\nC [libsystem_pthread.dylib+0x6f94] _pthread_start+0x88\nC [libsystem_pthread.dylib+0x1d34] thread_start+0x8\n","source_type":"crashtracking","stack":{"format":"CrashTrackerV1","frames":[{"function":"VMError::report_and_die()","line":0},{"function":"report_vm_error(char const*, int, char const*, char const*)","line":0},{"function":"report_java_out_of_memory(char const*)","line":0},{"function":"CollectedHeap::common_mem_allocate_noinit(KlassHandle, unsigned long, Thread*)","line":0},{"function":"TypeArrayKlass::allocate_common(int, bool, Thread*)","line":0},{"function":"InterpreterRuntime::newarray(JavaThread*, BasicType, int)","line":0},{"function":"datadog.smoketest.crashtracking.CrashtrackingTestApplication.main([Ljava/lang/String;)V","line":0},{"function":" ~StubRoutines::call_stub","line":0},{"function":"JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*)","line":0},{"function":"jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)","line":0},{"function":"jni_CallStaticVoidMethod","line":0},{"function":"JavaMain","line":0},{"function":"_pthread_start","line":0},{"function":"thread_start","line":0}]}},"incomplete":false,"metadata":{"family":"java","library_name":"dd-trace-java","library_version":"1.42.0-SNAPSHOT~aa29078ace","tags":{}},"os_info":{"architecture":"aarch64","bitness":"64","os_type":"Mac OS X","version":{"Semantic":[14,7,0]}},"proc_info":{"pid":"96267"},"uuid":"bfe4e4b4-b59f-4954-bee3-91f60e653e61","version_id":0}

0 commit comments

Comments
 (0)