Skip to content

Commit cb1388a

Browse files
committed
Merge remote-tracking branch 'origin/master' into bdu/bdu-muzzle-dedicated-class-tasks
2 parents 72344a0 + 713a41a commit cb1388a

File tree

1,514 files changed

+11160
-1771
lines changed

Some content is hidden

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

1,514 files changed

+11160
-1771
lines changed

.github/CODEOWNERS

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
/.gitlab/ @DataDog/apm-release-platform
1313
/.gitlab-ci.yml @DataDog/apm-release-platform
1414

15-
# @DataDog/apm-sdk-api-java
16-
/dd-java-agent/agent-otel @DataDog/apm-sdk-api-java
17-
/dd-smoke-tests/sample-trace @DataDog/apm-sdk-api-java
18-
/dd-trace-core/src/main/java/datadog/trace/core/baggage @DataDog/apm-sdk-api-java
19-
/dd-trace-core/src/test/groovy/datadog/trace/core/baggage @DataDog/apm-sdk-api-java
20-
/dd-trace-core/src/main/java/datadog/trace/core/propagation @DataDog/apm-sdk-api-java
21-
/dd-trace-core/src/test/groovy/datadog/trace/core/propagation @DataDog/apm-sdk-api-java
22-
/dd-trace-core/src/main/java/datadog/trace/core/scopemanager @DataDog/apm-sdk-api-java
23-
/dd-trace-core/src/test/groovy/datadog/trace/core/scopemanager @DataDog/apm-sdk-api-java
24-
/dd-trace-ot/ @DataDog/apm-sdk-api-java
25-
/internal-api/src/main/java/datadog/trace/bootstrap @DataDog/apm-sdk-api-java
26-
/internal-api/src/test/groovy/datadog/trace/bootstrap @DataDog/apm-sdk-api-java
27-
/internal-api/src/main/java/datadog/trace/api/sampling @DataDog/apm-sdk-api-java
28-
/internal-api/src/test/groovy/datadog/trace/api/sampling @DataDog/apm-sdk-api-java
15+
# @DataDog/apm-sdk-capabilities-java
16+
/dd-java-agent/agent-otel @DataDog/apm-sdk-capabilities-java
17+
/dd-smoke-tests/sample-trace @DataDog/apm-sdk-capabilities-java
18+
/dd-trace-core/src/main/java/datadog/trace/core/baggage @DataDog/apm-sdk-capabilities-java
19+
/dd-trace-core/src/test/groovy/datadog/trace/core/baggage @DataDog/apm-sdk-capabilities-java
20+
/dd-trace-core/src/main/java/datadog/trace/core/propagation @DataDog/apm-sdk-capabilities-java
21+
/dd-trace-core/src/test/groovy/datadog/trace/core/propagation @DataDog/apm-sdk-capabilities-java
22+
/dd-trace-core/src/main/java/datadog/trace/core/scopemanager @DataDog/apm-sdk-capabilities-java
23+
/dd-trace-core/src/test/groovy/datadog/trace/core/scopemanager @DataDog/apm-sdk-capabilities-java
24+
/dd-trace-ot/ @DataDog/apm-sdk-capabilities-java
25+
/internal-api/src/main/java/datadog/trace/bootstrap @DataDog/apm-sdk-capabilities-java
26+
/internal-api/src/test/groovy/datadog/trace/bootstrap @DataDog/apm-sdk-capabilities-java
27+
/internal-api/src/main/java/datadog/trace/api/sampling @DataDog/apm-sdk-capabilities-java
28+
/internal-api/src/test/groovy/datadog/trace/api/sampling @DataDog/apm-sdk-capabilities-java
2929

3030
# @DataDog/apm-serverless
3131
/dd-trace-core/src/main/java/datadog/trace/lambda/ @DataDog/apm-serverless
@@ -77,16 +77,14 @@
7777
/dd-java-agent/agent-ci-visibility/ @DataDog/ci-app-libraries-java
7878
/dd-java-agent/instrumentation/cucumber/ @DataDog/ci-app-libraries-java
7979
/dd-java-agent/instrumentation/jacoco/ @DataDog/ci-app-libraries-java
80-
/dd-java-agent/instrumentation/junit-4.10/ @DataDog/ci-app-libraries-java
81-
/dd-java-agent/instrumentation/junit-5.3/ @DataDog/ci-app-libraries-java
80+
/dd-java-agent/instrumentation/junit @DataDog/ci-app-libraries-java
8281
/dd-java-agent/instrumentation/karate/ @DataDog/ci-app-libraries-java
8382
/dd-java-agent/instrumentation/scalatest/ @DataDog/ci-app-libraries-java
8483
/dd-java-agent/instrumentation/selenium/ @DataDog/ci-app-libraries-java
8584
/dd-java-agent/instrumentation/testng/ @DataDog/ci-app-libraries-java
86-
/dd-java-agent/instrumentation/gradle-3.0/ @DataDog/ci-app-libraries-java
87-
/dd-java-agent/instrumentation/gradle-8.3/ @DataDog/ci-app-libraries-java
85+
/dd-java-agent/instrumentation/gradle/ @DataDog/ci-app-libraries-java
8886
/dd-java-agent/instrumentation/gradle-testing/ @DataDog/ci-app-libraries-java
89-
/dd-java-agent/instrumentation/maven-3.2.1/ @DataDog/ci-app-libraries-java
87+
/dd-java-agent/instrumentation/maven @DataDog/ci-app-libraries-java
9088
/dd-java-agent/instrumentation/maven-surefire/ @DataDog/ci-app-libraries-java
9189
/dd-java-agent/instrumentation/weaver/ @DataDog/ci-app-libraries-java
9290
/dd-smoke-tests/gradle/ @DataDog/ci-app-libraries-java

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Contributor Checklist
88

99
- Format the title [according the contribution guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#title-format)
10-
- Assign the `type:` and (`comp:` or `inst:`) labels in addition to [any usefull labels](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#labels)
10+
- Assign the `type:` and (`comp:` or `inst:`) labels in addition to [any useful labels](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#labels)
1111
- Don't use `close`, `fix` or any [linking keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) when referencing an issue.
1212
Use `solves` instead, and assign the PR [milestone](https://github.com/DataDog/dd-trace-java/milestones) to the issue
1313
- Update the [CODEOWNERS](https://github.com/DataDog/dd-trace-java/blob/master/.github/CODEOWNERS) file on source file addition, move, or deletion

.github/workflows/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ _Action:_ Check the pull request complies with [the contribution guidelines](htt
2828

2929
_Recovery:_ Manually verify the guideline compliance.
3030

31+
### check-pull-request-labels [🔗](check-pull-request-labels.yaml)
32+
33+
_Trigger:_ When creating or updating a pull request.
34+
35+
_Action:_ Check the pull request did not introduce unexpected label.
36+
37+
_Recovery:_ Update the pull request or add a comment to trigger the action again.
38+
3139
### draft-release-notes-on-tag [🔗](draft-release-notes-on-tag.yaml)
3240

3341
_Trigger:_ When creating a tag, or manually (providing a tag)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Validate PR Label Format
2+
on:
3+
pull_request:
4+
types: [opened, edited, ready_for_review, labeled]
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
check_pr_labels:
12+
name: Check pull request labels
13+
permissions:
14+
issues: write
15+
pull-requests: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check pull request labels
19+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # 8.0.0
20+
with:
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
script: |
23+
// Skip draft pull requests
24+
if (context.payload.pull_request.draft) {
25+
return
26+
}
27+
// Define valid label categories
28+
const validCategories = [
29+
'type:',
30+
'comp:',
31+
'inst:',
32+
'tag:',
33+
'performance:', // To refactor to 'ci: ' in the future
34+
'run-tests:' // Unused since GitLab migration
35+
]
36+
// Look for invalid labels
37+
const invalidLabels = context.payload.pull_request.labels
38+
.map(label => label.name)
39+
.filter(label => validCategories.every(prefix => !label.startsWith(prefix)))
40+
const hasInvalidLabels = invalidLabels.length > 0
41+
// Get existing comments to check for blocking comment
42+
const comments = await github.rest.issues.listComments({
43+
issue_number: context.payload.pull_request.number,
44+
owner: context.repo.owner,
45+
repo: context.repo.repo
46+
})
47+
const commentMarker = '<!-- dd-trace-java-check-pr-labels-workflow -->'
48+
const blockingComment = comments.data.find(comment => comment.body.includes(commentMarker))
49+
// Create or update blocking comment if there are invalid labels
50+
if (hasInvalidLabels) {
51+
const commentBody = '**PR Blocked - Invalid Label**\n\n' +
52+
`The pull request introduced unexpected labels:\n\n` +
53+
invalidLabels.map(label => `* \`${label}\``).join('\n') + '\n\n' +
54+
'**This PR is blocked until:**\n' +
55+
'1. The invalid labels are deleted, and\n' +
56+
'2. A maintainer deletes this comment to unblock the PR\n\n' +
57+
'**Note:** Simply removing labels from the pull request is not enough - a maintainer must remove the label and delete this comment to remove the block.\n\n' +
58+
commentMarker
59+
60+
if (blockingComment) {
61+
// Update existing blocking comment
62+
await github.rest.issues.updateComment({
63+
comment_id: blockingComment.id,
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
body: commentBody
67+
})
68+
} else {
69+
// Create new blocking comment
70+
await github.rest.issues.createComment({
71+
issue_number: context.payload.pull_request.number,
72+
owner: context.repo.owner,
73+
repo: context.repo.repo,
74+
body: commentBody
75+
})
76+
}
77+
blockingComment = true
78+
}
79+
if (blockingComment) {
80+
// Block the PR by failing the workflow
81+
core.setFailed(`PR blocked: Invalid labels detected: (${invalidLabels.join(', ')}). A maintainer must delete the blocking comment after fixing the labels to allow merging.`)
82+
}

BUILDING.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ Requirements to build the full project:
6363

6464
Download and install JDK versions 8, 11, 17, 21 and 25, and GraalVM 17 for your OS.
6565

66-
> [!NOTE]
67-
> While Temurin JDK 25 from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) has not been released, please download the OpenJDK EA version at [this link](https://jdk.java.net/25/). Add the required environment variable using an `export` command along the lines of `export JAVA_25_HOME=/Library/Java/JavaVirtualMachines/jdk-25.jdk/Contents/Home`. Then, confirm that this was set properly by executing `echo $JAVA_25_HOME`.
68-
6966
#### macOS
7067

7168
* Install the required JDKs using `brew`:

build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ import com.diffplug.gradle.spotless.SpotlessExtension
33
plugins {
44
id("datadog.gradle-debug")
55
id("datadog.dependency-locking")
6+
id("datadog.tracer-version")
7+
id("datadog.dump-hanged-test")
68

79
id("com.diffplug.spotless") version "6.13.0"
810
id("com.github.spotbugs") version "5.0.14"
911
id("de.thetaphi.forbiddenapis") version "3.8"
10-
11-
id("tracer-version")
1212
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
13-
1413
id("com.gradleup.shadow") version "8.3.6" apply false
1514
id("me.champeau.jmh") version "0.7.3" apply false
1615
id("org.gradle.playframework") version "0.13" apply false
17-
id("info.solidsoft.pitest") version "1.9.11" apply false
1816
}
1917

2018
description = "dd-trace-java"

buildSrc/build.gradle.kts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,21 @@ gradlePlugin {
2727
implementationClass = "datadog.gradle.plugin.CallSiteInstrumentationPlugin"
2828
}
2929
create("tracer-version-plugin") {
30-
id = "tracer-version"
30+
id = "datadog.tracer-version"
3131
implementationClass = "datadog.gradle.plugin.version.TracerVersionPlugin"
3232
}
33+
create("dump-hanged-test-plugin") {
34+
id = "datadog.dump-hanged-test"
35+
implementationClass = "datadog.gradle.plugin.dump.DumpHangedTestPlugin"
36+
}
37+
create("supported-config-generation") {
38+
id = "supported-config-generator"
39+
implementationClass = "datadog.gradle.plugin.config.SupportedConfigPlugin"
40+
}
41+
create("supported-config-linter") {
42+
id = "config-inversion-linter"
43+
implementationClass = "datadog.gradle.plugin.config.ConfigInversionLinter"
44+
}
3345
}
3446
}
3547

@@ -52,6 +64,11 @@ dependencies {
5264
implementation("com.google.guava", "guava", "20.0")
5365
implementation("org.ow2.asm", "asm", "9.8")
5466
implementation("org.ow2.asm", "asm-tree", "9.8")
67+
68+
implementation(platform("com.fasterxml.jackson:jackson-bom:2.17.2"))
69+
implementation("com.fasterxml.jackson.core:jackson-databind")
70+
implementation("com.fasterxml.jackson.core:jackson-annotations")
71+
implementation("com.fasterxml.jackson.core:jackson-core")
5572
}
5673

5774
tasks.compileKotlin {
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
package datadog.gradle.plugin.version
2+
3+
import org.gradle.testkit.runner.GradleRunner
4+
import org.gradle.testkit.runner.UnexpectedBuildFailure
5+
import org.junit.jupiter.api.Assertions.assertFalse
6+
import org.junit.jupiter.api.Assertions.assertTrue
7+
import org.junit.jupiter.api.Test
8+
import org.junit.jupiter.api.assertNotNull
9+
import org.junit.jupiter.api.io.TempDir
10+
import java.io.File
11+
import java.nio.file.Paths
12+
13+
class DumpHangedTestIntegrationTest {
14+
@Test
15+
fun `should not take dumps`(@TempDir projectDir: File) {
16+
val output = runGradleTest(projectDir, testSleep = 1000)
17+
18+
// Assert Gradle output has no evidence of taking dumps.
19+
assertFalse(output.contains("Taking dumps after 15 seconds delay for :test"))
20+
assertFalse(output.contains("Requesting stop of task ':test' as it has exceeded its configured timeout of 20s."))
21+
22+
assertTrue(file(projectDir, "build").exists()) // Assert build happened.
23+
assertFalse(file(projectDir, "build", "dumps").exists()) // Assert no dumps created.
24+
}
25+
26+
@Test
27+
fun `should take dumps`(@TempDir projectDir: File) {
28+
val output = runGradleTest(projectDir, testSleep = 25_0000)
29+
30+
// Assert Gradle output has evidence of taking dumps.
31+
assertTrue(output.contains("Taking dumps after 15 seconds delay for :test"))
32+
assertTrue(output.contains("Requesting stop of task ':test' as it has exceeded its configured timeout of 20s."))
33+
34+
assertTrue(file(projectDir, "build").exists()) // Assert build happened.
35+
36+
val dumps = file(projectDir, "build", "dumps")
37+
assertTrue(dumps.exists()) // Assert dumps created.
38+
39+
// Assert actual dumps created.
40+
val dumpFiles = dumps.list()
41+
assertNotNull(dumpFiles.find { it.endsWith(".hprof") })
42+
assertNotNull(dumpFiles.find { it.startsWith("all-thread-dumps") })
43+
}
44+
45+
private fun runGradleTest(projectDir: File, testSleep: Long): List<String> {
46+
file(projectDir, "settings.gradle.kts").writeText(
47+
"""
48+
rootProject.name = "test-project"
49+
""".trimIndent()
50+
)
51+
52+
file(projectDir, "build.gradle.kts").writeText(
53+
"""
54+
import java.time.Duration
55+
56+
plugins {
57+
id("java")
58+
id("datadog.dump-hanged-test")
59+
}
60+
61+
group = "datadog.dump.test"
62+
63+
repositories {
64+
mavenCentral()
65+
}
66+
67+
dependencies {
68+
testImplementation(platform("org.junit:junit-bom:5.10.0"))
69+
testImplementation("org.junit.jupiter:junit-jupiter")
70+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
71+
}
72+
73+
dumpHangedTest {
74+
// Set the dump offset for 5 seconds to trigger taking dumps after 15 seconds.
75+
dumpOffset.set(5)
76+
}
77+
78+
tasks.withType<Test>().configureEach {
79+
// Set test timeout after 20 seconds.
80+
timeout.set(Duration.ofSeconds(20))
81+
82+
useJUnitPlatform()
83+
}
84+
""".trimIndent()
85+
)
86+
87+
file(projectDir, "src", "test", "java", "SimpleTest.java", makeDirectory = true).writeText(
88+
"""
89+
import org.junit.jupiter.api.Test;
90+
91+
public class SimpleTest {
92+
@Test
93+
public void test() throws InterruptedException {
94+
Thread.sleep($testSleep);
95+
}
96+
}
97+
""".trimIndent()
98+
)
99+
100+
try {
101+
val buildResult = GradleRunner.create()
102+
.forwardOutput()
103+
.withPluginClasspath()
104+
.withArguments("test")
105+
.withProjectDir(projectDir)
106+
.build()
107+
108+
return buildResult.output.lines()
109+
} catch (e: UnexpectedBuildFailure) {
110+
return e.buildResult.output.lines()
111+
}
112+
}
113+
114+
private fun file(projectDir: File, vararg parts: String, makeDirectory: Boolean = false): File {
115+
val f = Paths.get(projectDir.absolutePath, *parts).toFile()
116+
117+
if (makeDirectory) {
118+
f.parentFile.mkdirs()
119+
}
120+
121+
return f
122+
}
123+
}

buildSrc/src/integTest/kotlin/datadog/gradle/plugin/version/TracerVersionIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class TracerVersionIntegrationTest {
265265
File(projectDir, "build.gradle.kts").writeText(
266266
"""
267267
plugins {
268-
id("tracer-version")
268+
id("datadog.tracer-version")
269269
}
270270
271271
tasks.register("printVersion") {

buildSrc/src/main/groovy/InstrumentingPlugin.groovy

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,19 @@ class InstrumentingPlugin {
4949
.withErrorHandlers(
5050
Plugin.Engine.ErrorHandler.Enforcing.ALL_TYPES_RESOLVED,
5151
Plugin.Engine.ErrorHandler.Enforcing.NO_LIVE_INITIALIZERS,
52-
Plugin.Engine.ErrorHandler.Failing.FAIL_LAST)
52+
new Plugin.Engine.ErrorHandler() {
53+
@Delegate
54+
Plugin.Engine.ErrorHandler delegate = Plugin.Engine.ErrorHandler.Failing.FAIL_LAST
55+
56+
void onError(Map<TypeDescription, List<Throwable>> throwables) {
57+
throw new IllegalStateException("Failed to transform at least one type: " + throwables).tap { ise ->
58+
throwables.values().flatten().each {
59+
ise.addSuppressed(it)
60+
}
61+
};
62+
}
63+
}
64+
)
5365
.with(Plugin.Engine.Dispatcher.ForSerialTransformation.Factory.INSTANCE)
5466
.apply(source, target, factories)
5567

0 commit comments

Comments
 (0)