Skip to content

Commit e1a52bc

Browse files
committed
Merge branch 'master' into sarahchen6/move-macrobenchmarks
2 parents 6c41b8c + 89639f7 commit e1a52bc

File tree

395 files changed

+3297
-1520
lines changed

Some content is hidden

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

395 files changed

+3297
-1520
lines changed

.github/workflows/analyze-changes.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
${{ runner.os }}-gradle-
3131
3232
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
33+
uses: github/codeql-action/init@fe4161a26a8629af62121b670040955b330f9af2 # v4.31.6
3434
with:
3535
languages: 'java'
3636
build-mode: 'manual'
@@ -49,7 +49,7 @@ jobs:
4949
--build-cache --parallel --stacktrace --no-daemon --max-workers=4
5050
5151
- name: Perform CodeQL Analysis and upload results to GitHub Security tab
52-
uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
52+
uses: github/codeql-action/analyze@fe4161a26a8629af62121b670040955b330f9af2 # v4.31.6
5353

5454
trivy:
5555
name: Analyze changes with Trivy
@@ -114,7 +114,7 @@ jobs:
114114
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
115115

116116
- name: Upload Trivy scan results to GitHub Security tab
117-
uses: github/codeql-action/upload-sarif@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
117+
uses: github/codeql-action/upload-sarif@fe4161a26a8629af62121b670040955b330f9af2 # v4.31.6
118118
if: always()
119119
with:
120120
sarif_file: 'trivy-results.sarif'

.github/workflows/run-system-tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
build:
2222
runs-on:
2323
group: APM Larger Runners
24+
environment:
25+
name: ci-build
2426
steps:
2527
- name: Checkout repository
2628
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0

.gitlab-ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@ spotless:
367367
extends: .gradle_build
368368
stage: tests
369369
needs: []
370+
variables:
371+
# TODO: Latest version of spotless is failing with OOM on CI only.
372+
# Setting 8G memory solving this issue, but we need to solve it eventually.
373+
GRADLE_MEM: 8G
374+
KUBERNETES_MEMORY_REQUEST: 18Gi
375+
KUBERNETES_MEMORY_LIMIT: 18Gi
370376
script:
371377
- ./gradlew --version
372378
- ./gradlew spotlessCheck $GRADLE_ARGS

build.gradle.kts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
id("dd-trace-java.config-inversion-linter")
1010
id("dd-trace-java.ci-jobs")
1111

12-
id("com.diffplug.spotless") version "6.13.0"
12+
id("com.diffplug.spotless") version "8.1.0"
1313
id("com.github.spotbugs") version "6.4.7"
1414
id("de.thetaphi.forbiddenapis") version "3.10"
1515
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
@@ -36,7 +36,7 @@ with(extensions["spotlessPredeclare"] as SpotlessExtension) {
3636
removeUnusedImports()
3737

3838
// This is the last Google Java Format version that supports Java 8
39-
googleJavaFormat("1.7")
39+
googleJavaFormat("1.32.0")
4040
}
4141
groovyGradle {
4242
greclipse()
@@ -45,13 +45,14 @@ with(extensions["spotlessPredeclare"] as SpotlessExtension) {
4545
greclipse()
4646
}
4747
kotlinGradle {
48-
ktlint("0.41.0")
48+
ktlint("1.8.0")
4949
}
5050
kotlin {
51-
ktlint("0.41.0")
51+
ktlint("1.8.0")
5252
}
5353
scala {
54-
scalafmt("2.7.5")
54+
// TODO: For some reason Scala format is working correctly with this version only.
55+
scalafmt("3.8.6")
5556
}
5657
}
5758
apply(from = rootDir.resolve("gradle/spotless.gradle"))
@@ -145,7 +146,8 @@ testAggregate("instrumentation", listOf(":dd-java-agent:instrumentation"), empty
145146
testAggregate("profiling", listOf(":dd-java-agent:agent-profiling"), emptyList())
146147
testAggregate("debugger", listOf(":dd-java-agent:agent-debugger"), forceCoverage = true)
147148
testAggregate(
148-
"base", listOf(":"),
149+
"base",
150+
listOf(":"),
149151
listOf(
150152
":dd-java-agent:instrumentation",
151153
":dd-smoke-tests",

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
`java-gradle-plugin`
44
`kotlin-dsl`
55
`jvm-test-suite`
6-
id("com.diffplug.spotless") version "6.13.0"
6+
id("com.diffplug.spotless") version "8.1.0"
77
}
88

99
java {

buildSrc/call-site-instrumentation-plugin/build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
java
33
groovy
4-
id("com.diffplug.spotless") version "6.13.0"
4+
id("com.diffplug.spotless") version "8.1.0"
55
id("com.gradleup.shadow") version "8.3.6"
66
}
77

@@ -17,8 +17,7 @@ spotless {
1717
target("src/**/*.java")
1818
// ignore embedded test projects
1919
targetExclude("src/test/resources/**")
20-
// This is the last Google Java Format version that supports Java 8
21-
googleJavaFormat("1.7")
20+
googleJavaFormat("1.32.0")
2221
}
2322
}
2423

buildSrc/src/main/kotlin/datadog/gradle/plugin/config/ConfigInversionLinter.kt

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,40 @@ class ConfigInversionLinter : Plugin<Project> {
2626
}
2727
}
2828

29+
// Data class for fields from generated class
30+
private data class LoadedConfigFields(
31+
val supported: Set<String>,
32+
val aliasMapping: Map<String, String> = emptyMap()
33+
)
34+
35+
// Cache for fields from generated class
36+
private var cachedConfigFields: LoadedConfigFields? = null
37+
38+
// Helper function to load fields from the generated class
39+
private fun loadConfigFields(
40+
mainSourceSetOutput: org.gradle.api.file.FileCollection,
41+
generatedClassName: String
42+
): LoadedConfigFields {
43+
return cachedConfigFields ?: run {
44+
val urls = mainSourceSetOutput.files.map { it.toURI().toURL() }.toTypedArray()
45+
URLClassLoader(urls, LoadedConfigFields::class.java.classLoader).use { cl ->
46+
val clazz = Class.forName(generatedClassName, true, cl)
47+
48+
val supportedField = clazz.getField("SUPPORTED").get(null)
49+
@Suppress("UNCHECKED_CAST")
50+
val supportedSet = when (supportedField) {
51+
is Set<*> -> supportedField as Set<String>
52+
is Map<*, *> -> supportedField.keys as Set<String>
53+
else -> throw IllegalStateException("SUPPORTED field must be either Set<String> or Map<String, Any>, but was ${supportedField?.javaClass}")
54+
}
55+
56+
@Suppress("UNCHECKED_CAST")
57+
val aliasMappingMap = clazz.getField("ALIAS_MAPPING").get(null) as Map<String, String>
58+
LoadedConfigFields(supportedSet, aliasMappingMap)
59+
}.also { cachedConfigFields = it }
60+
}
61+
}
62+
2963
/** Registers `logEnvVarUsages` (scan for DD_/OTEL_ tokens and fail if unsupported). */
3064
private fun registerLogEnvVarUsages(target: Project, extension: SupportedTracerConfigurations) {
3165
val ownerPath = extension.configOwnerPath
@@ -52,16 +86,11 @@ private fun registerLogEnvVarUsages(target: Project, extension: SupportedTracerC
5286
inputs.files(javaFiles)
5387
outputs.upToDateWhen { true }
5488
doLast {
55-
// 1) Build classloader from the owner project’s runtime classpath
56-
val urls = mainSourceSetOutput.get().get().files.map { it.toURI().toURL() }.toTypedArray()
57-
val supported: Set<String> = URLClassLoader(urls, javaClass.classLoader).use { cl ->
58-
// 2) Load the generated class + read static field
59-
val clazz = Class.forName(generatedFile.get(), true, cl)
60-
@Suppress("UNCHECKED_CAST")
61-
clazz.getField("SUPPORTED").get(null) as Set<String>
62-
}
89+
// 1) Load configuration fields from the generated class
90+
val configFields = loadConfigFields(mainSourceSetOutput.get().get(), generatedFile.get())
91+
val supported = configFields.supported
6392

64-
// 3) Scan our sources and compare
93+
// 2) Scan our sources and compare
6594
val repoRoot = target.projectDir.toPath()
6695
val tokenRegex = Regex("\"(?:DD_|OTEL_)[A-Za-z0-9_]+\"")
6796

@@ -79,7 +108,7 @@ private fun registerLogEnvVarUsages(target: Project, extension: SupportedTracerC
79108
}
80109
tokenRegex.findAll(raw).forEach { m ->
81110
val token = m.value.trim('"')
82-
if (token !in supported) add("$rel:${i + 1} -> Unsupported token'$token'")
111+
if (token !in supported) add("$rel:${i + 1} -> Unsupported token '$token'")
83112
}
84113
}
85114
}
@@ -167,15 +196,9 @@ private fun registerCheckConfigStringsTask(project: Project, extension: Supporte
167196
throw GradleException("Config directory not found: ${configDir.absolutePath}")
168197
}
169198

170-
val urls = mainSourceSetOutput.get().get().files.map { it.toURI().toURL() }.toTypedArray()
171-
val (supported, aliasMapping) = URLClassLoader(urls, javaClass.classLoader).use { cl ->
172-
val clazz = Class.forName(generatedFile.get(), true, cl)
173-
@Suppress("UNCHECKED_CAST")
174-
val supportedSet = clazz.getField("SUPPORTED").get(null) as Set<String>
175-
@Suppress("UNCHECKED_CAST")
176-
val aliasMappingMap = clazz.getField("ALIAS_MAPPING").get(null) as Map<String, String>
177-
Pair(supportedSet, aliasMappingMap)
178-
}
199+
val configFields = loadConfigFields(mainSourceSetOutput.get().get(), generatedFile.get())
200+
val supported = configFields.supported
201+
val aliasMapping = configFields.aliasMapping
179202

180203
var parserConfig = ParserConfiguration()
181204
parserConfig.setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_8)
@@ -192,23 +215,23 @@ private fun registerCheckConfigStringsTask(project: Project, extension: Supporte
192215
.map { it as? FieldDeclaration }
193216
.ifPresent { field ->
194217
if (field.hasModifiers(Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC, Modifier.Keyword.FINAL) &&
195-
varDecl.typeAsString == "String") {
218+
varDecl.typeAsString == "String") {
196219

197-
val fieldName = varDecl.nameAsString
198-
if (fieldName.endsWith("_DEFAULT")) return@ifPresent
199-
val init = varDecl.initializer.orElse(null) ?: return@ifPresent
220+
val fieldName = varDecl.nameAsString
221+
if (fieldName.endsWith("_DEFAULT")) return@ifPresent
222+
val init = varDecl.initializer.orElse(null) ?: return@ifPresent
200223

201-
if (init !is StringLiteralExpr) return@ifPresent
202-
val rawValue = init.value
224+
if (init !is StringLiteralExpr) return@ifPresent
225+
val rawValue = init.value
203226

204-
val normalized = normalize(rawValue)
205-
if (normalized !in supported && normalized !in aliasMapping) {
206-
val line = varDecl.range.map { it.begin.line }.orElse(1)
207-
add("$fileName:$line -> Config '$rawValue' normalizes to '$normalized' " +
208-
"which is missing from '${extension.jsonFile.get()}'")
227+
val normalized = normalize(rawValue)
228+
if (normalized !in supported && normalized !in aliasMapping) {
229+
val line = varDecl.range.map { it.begin.line }.orElse(1)
230+
add("$fileName:$line -> Config '$rawValue' normalizes to '$normalized' " +
231+
"which is missing from '${extension.jsonFile.get()}'")
232+
}
209233
}
210234
}
211-
}
212235
}
213236
}
214237
}

components/context/src/main/java/datadog/context/ContextKey.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
*/
1111
public final class ContextKey<T> {
1212
private static final AtomicInteger NEXT_INDEX = new AtomicInteger(0);
13+
1314
/** The key name, for debugging purpose only. */
1415
private final String name;
16+
1517
/** The key unique context, related to {@link IndexedContext} implementation. */
1618
final int index;
1719

components/context/src/main/java/datadog/context/propagation/Concern.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
public class Concern {
99
/** The concern default priority. */
1010
public static final int DEFAULT_PRIORITY = 100;
11+
1112
/** The concern name, for debugging purpose only. */
1213
private final String name;
14+
1315
/** The concern priority, lower value means higher priority. */
1416
private final int priority;
1517

dd-java-agent/agent-bootstrap/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,4 @@ tasks.withType(Test).configureEach {
7373
JavaVersion.VERSION_16,
7474
['--add-opens', 'java.base/java.net=ALL-UNNAMED'] // for HostNameResolverForkedTest
7575
)
76-
7776
}

0 commit comments

Comments
 (0)