Skip to content

Commit 36aa9f2

Browse files
authored
Merge branch 'master' into sarahchen6/combine-release-branch-workflows
2 parents d7c580b + 9fccbf4 commit 36aa9f2

35 files changed

Lines changed: 1275 additions & 181 deletions

File tree

.github/chainguard/self.enforce-datadog-merge-queue.comment-pr.sts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ subject: repo:DataDog/dd-trace-java:pull_request
44

55
claim_pattern:
66
event_name: pull_request
7-
job_workflow_ref: DataDog/dd-trace-java/\.github/workflows/enforce-datadog-merge-queue\.yaml@refs/heads/master
7+
job_workflow_ref: DataDog/dd-trace-java/\.github/workflows/enforce-datadog-merge-queue\.yaml@refs/pull/[0-9]+/merge
88

99
permissions:
1010
issues: write

AGENTS.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,20 @@ It ships ~120 integrations (~200 instrumentations) for tracing, profiling, AppSe
77

88
## Project layout
99

10+
See [ARCHITECTURE.md](ARCHITECTURE.md) for detailed module descriptions.
11+
1012
```
11-
dd-java-agent/ Main agent
12-
instrumentation/ All auto-instrumentations (one dir per framework)
13-
agent-bootstrap/ Bootstrap classloader classes
14-
agent-builder/ Agent build & bytecode weaving
15-
agent-tooling/ Shared tooling for instrumentations
16-
agent-{product}/ Product-specific modules (ci-visibility, iast, profiling, debugger, llmobs, aiguard, ...)
17-
appsec/ Application Security (WAF, threat detection)
13+
dd-java-agent/ Main agent (shadow jar, instrumentations, product modules)
1814
dd-trace-api/ Public API & configuration constants
1915
dd-trace-core/ Core tracing engine (spans, propagation, writer)
20-
dd-trace-ot/ OpenTracing compatibility layer
16+
dd-trace-ot/ Legacy OpenTracing compatibility library
2117
internal-api/ Internal shared API across modules
18+
components/ Shared low-level components (context, environment, json)
2219
products/ Sub-products (feature flagging, metrics)
2320
communication/ HTTP transport to Datadog Agent
24-
components/ Shared low-level components
2521
remote-config/ Remote configuration support
2622
telemetry/ Agent telemetry
2723
utils/ Shared utility modules (config, time, socket, test, etc.)
28-
metadata/ Supported configurations metadata & requirements
29-
benchmark/ Performance benchmarks
3024
dd-smoke-tests/ Smoke tests (real apps + agent)
3125
docs/ Developer documentation (see below)
3226
```
@@ -35,6 +29,7 @@ docs/ Developer documentation (see below)
3529

3630
| Topic | File |
3731
|---|---|
32+
| Architecture & design | [ARCHITECTURE.md](ARCHITECTURE.md) |
3833
| Building from source | [BUILDING.md](BUILDING.md) |
3934
| Contributing & PR guidelines | [CONTRIBUTING.md](CONTRIBUTING.md) |
4035
| How instrumentations work | [docs/how_instrumentations_work.md](docs/how_instrumentations_work.md) |

ARCHITECTURE.md

Lines changed: 292 additions & 0 deletions
Large diffs are not rendered by default.

buildSrc/src/main/kotlin/datadog/gradle/plugin/dump/DumpHangedTestPlugin.kt

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,30 +123,37 @@ class DumpHangedTestPlugin : Plugin<Project> {
123123
fun file(name: String, ext: String = "log") =
124124
File(dumpsDir, "$name-${System.currentTimeMillis()}.$ext")
125125

126-
// For simplicity, use `0` as the PID, which collects all thread dumps across JVMs.
127-
val allThreadsFile = file("all-thread-dumps")
128-
runCmd(Redirect.to(allThreadsFile), "jcmd", "0", "Thread.print", "-l")
129-
130126
// Collect all JVMs pids.
131127
val allJavaProcessesFile = file("all-java-processes")
132128
runCmd(Redirect.to(allJavaProcessesFile), "jcmd", "-l")
133129

134-
// Collect pids for 'Gradle Test Executor'.
135-
val pids = allJavaProcessesFile.readLines()
136-
.filter { it.contains("Gradle Test Executor") }
137-
.map { it.substringBefore(' ') }
130+
// On IBM JDK thread dump can be collected by signaling the matching `Gradle Test Executor` process with `kill -3`.
131+
// It will be writen into `/tmp/javacore.YYYYMMDD.HHMMSS.PID.SEQ.txt
132+
if (isIbm8(allJavaProcessesFile)) {
133+
val allProcessesFile = file("all-processes")
134+
runCmd(Redirect.to(allProcessesFile), "ps", "-ef")
135+
extractPidsIbm8(allProcessesFile).forEach { ibm8Pid ->
136+
runCmd(Redirect.INHERIT, "kill", "-3", ibm8Pid)
137+
}
138+
} else {
139+
val pids = extractPids(allJavaProcessesFile)
138140

139-
pids.forEach { pid ->
140-
// Collect heap dump by pid.
141-
val heapDumpPath = file("${pid}-heap-dump", "hprof").absolutePath
142-
runCmd(Redirect.INHERIT, "jcmd", pid, "GC.heap_dump", heapDumpPath)
141+
pids.forEach { pid ->
142+
// Collect heap dump by pid.
143+
val heapDumpPath = file("${pid}-heap-dump", "hprof").absolutePath
144+
runCmd(Redirect.INHERIT, "jcmd", pid, "GC.heap_dump", heapDumpPath)
143145

144-
// Collect thread dump by pid.
145-
val threadDumpFile = file("${pid}-thread-dump")
146-
runCmd(Redirect.to(threadDumpFile), "jcmd", pid, "Thread.print", "-l")
146+
// Collect thread dump by pid.
147+
val threadDumpFile = file("${pid}-thread-dump")
148+
runCmd(Redirect.to(threadDumpFile), "jcmd", pid, "Thread.print", "-l")
149+
}
150+
151+
// Just in case collect all thread dumps by using special PID `0`.
152+
val allThreadsFile = file("all-thread-dumps")
153+
runCmd(Redirect.to(allThreadsFile), "jcmd", "0", "Thread.print", "-l")
147154
}
148155
} catch (e: Throwable) {
149-
t.logger.warn("Taking dumps failed with error: ${e.message}, for ${t.path}")
156+
t.logger.warn("Taking dumps failed with error: ${e.message ?: e.javaClass.name}, for ${t.path}")
150157
}
151158
}
152159

@@ -175,4 +182,24 @@ class DumpHangedTestPlugin : Plugin<Project> {
175182
throw IOException("Process failed: ${args.joinToString(" ")}, exit code: $exitCode")
176183
}
177184
}
185+
186+
private fun isIbm8(file: File): Boolean =
187+
file.readLines().any { it.contains("-PtestJvm=ibm8") }
188+
189+
private fun extractPids(file: File): List<String> =
190+
file.readLines()
191+
.filter { it.contains("Gradle Test Executor") }
192+
.map { it.substringBefore(' ') }
193+
194+
private fun extractPidsIbm8(file: File): List<String> =
195+
file.readLines()
196+
.filter { it.contains("Gradle Test Executor") }
197+
.filter { it.contains("ibm", ignoreCase = true) }
198+
.mapNotNull(::extractPid)
199+
200+
private val whitespaceRegex = Regex("\\s+")
201+
202+
// ps -ef format produce output like: UID PID PPID ...
203+
private fun extractPid(line: String): String? =
204+
line.trimStart().split(whitespaceRegex, limit = 3).getOrNull(1)
178205
}

0 commit comments

Comments
 (0)