Skip to content

Commit 23f1013

Browse files
authored
Merge branch 'master' into mtoff/stable_cfg_2
2 parents cffcc17 + 8adba3f commit 23f1013

File tree

155 files changed

+2392
-1463
lines changed

Some content is hidden

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

155 files changed

+2392
-1463
lines changed

.circleci/config.continue.yml.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation
3636
debugger_modules: &debugger_modules "dd-java-agent/agent-debugger|dd-java-agent/agent-bootstrap|dd-java-agent/agent-builder|internal-api|communication|dd-trace-core"
3737
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"
3838

39-
default_system_tests_commit: &default_system_tests_commit 1de04c42cbd9783432258004e46eb5982bbc9fe5
39+
default_system_tests_commit: &default_system_tests_commit 55cc62fb333b8de1466f8a0ecfdfa55fe9f57031
4040

4141
parameters:
4242
nightly:

.gitlab-ci.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ variables:
2323
DEPENDENCY_CACHE_POLICY: pull
2424
BUILD_CACHE_POLICY: pull
2525
GRADLE_VERSION: "8.4" # must match gradle-wrapper.properties
26-
MAVEN_REPOSITORY_PROXY: "https://artifactual.us1.prod.dog/repository/maven-central/"
26+
MAVEN_REPOSITORY_PROXY: "http://artifactual.artifactual.all-clusters.local-dc.fabric.dog:8081/repository/maven-central/"
27+
GRADLE_PLUGIN_PROXY: "http://artifactual.artifactual.all-clusters.local-dc.fabric.dog:8081/repository/gradle-plugin-portal-proxy/"
2728
JAVA_BUILD_IMAGE_VERSION: "v25.01"
2829
REPO_NOTIFICATION_CHANNEL: "#apm-java-escalations"
2930
PROFILE_TESTS:
@@ -75,7 +76,7 @@ default:
7576
policy: $BUILD_CACHE_POLICY
7677
before_script:
7778
- export GRADLE_USER_HOME=`pwd`/.gradle
78-
- export GRADLE_ARGS=" --build-cache --stacktrace --no-daemon --parallel --max-workers=$GRADLE_WORKERS -PmavenRepositoryProxy=$MAVEN_REPOSITORY_PROXY"
79+
- export GRADLE_ARGS=" --build-cache --stacktrace --no-daemon --parallel --max-workers=$GRADLE_WORKERS -PmavenRepositoryProxy=$MAVEN_REPOSITORY_PROXY -PgradlePluginProxy=$GRADLE_PLUGIN_PROXY"
7980
- *normalize_node_index
8081
# for weird reasons, gradle will always "chmod 700" the .gradle folder
8182
# with Gitlab caching, .gradle is always owned by root and thus gradle's chmod invocation fails

build.gradle

+1-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ description = 'dd-trace-java'
3232

3333
def isCI = System.getenv("CI") != null
3434

35+
apply from: "$rootDir/gradle/repositories.gradle"
3536
apply from: "$rootDir/gradle/scm.gradle"
3637
spotless {
3738
// only resolve the spotless dependencies once in the build
@@ -79,12 +80,6 @@ allprojects {
7980
}
8081
}
8182

82-
repositories {
83-
mavenLocal()
84-
mavenCentral()
85-
gradlePluginPortal()
86-
}
87-
8883
tasks.register("latestDepTest")
8984

9085
nexusPublishing {

buildSrc/build.gradle.kts

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ gradlePlugin {
2222
}
2323
}
2424

25-
repositories {
26-
mavenLocal()
27-
mavenCentral()
28-
gradlePluginPortal()
25+
apply {
26+
from("$rootDir/../gradle/repositories.gradle")
2927
}
3028

3129
dependencies {

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ spotless {
2424
}
2525
}
2626

27-
repositories {
28-
mavenLocal()
29-
mavenCentral()
30-
gradlePluginPortal()
27+
apply {
28+
from("$rootDir/../gradle/repositories.gradle")
3129
}
3230

3331
dependencies {

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java

+5
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ public static void start(
250250
setSystemPropertyDefault(
251251
propertyNameToSystemPropertyName("integration.kafka.enabled"), "true");
252252

253+
if (Config.get().isDataJobsOpenLineageEnabled()) {
254+
setSystemPropertyDefault(
255+
propertyNameToSystemPropertyName("integration.spark-openlineage.enabled"), "true");
256+
}
257+
253258
String javaCommand = System.getProperty("sun.java.command");
254259
String dataJobsCommandPattern = Config.get().getDataJobsCommandPattern();
255260
if (!isDataJobsSupported(javaCommand, dataJobsCommandPattern)) {

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtensions.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ public Object apply(Object result, AgentSpan span) {
6161
}
6262
return null;
6363
}
64+
}
6465

65-
private <T> BiConsumer<T, Throwable> finishSpan(AgentSpan span) {
66-
return (o, throwable) -> {
67-
if (throwable != null) {
68-
span.addThrowable(
69-
throwable instanceof ExecutionException || throwable instanceof CompletionException
70-
? throwable.getCause()
71-
: throwable);
72-
}
73-
span.finish();
74-
};
75-
}
66+
public static <T> BiConsumer<T, Throwable> finishSpan(AgentSpan span) {
67+
return (o, throwable) -> {
68+
if (throwable != null) {
69+
span.addThrowable(
70+
throwable instanceof ExecutionException || throwable instanceof CompletionException
71+
? throwable.getCause()
72+
: throwable);
73+
}
74+
span.finish();
75+
};
7676
}
7777
}

dd-java-agent/agent-ci-visibility/build.gradle

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
buildscript {
22
repositories {
3+
mavenLocal()
4+
if (project.rootProject.hasProperty("gradlePluginProxy")) {
5+
maven {
6+
url project.rootProject.property("gradlePluginProxy")
7+
allowInsecureProtocol true
8+
}
9+
}
10+
if (project.rootProject.hasProperty("mavenRepositoryProxy")) {
11+
maven {
12+
url project.rootProject.property("mavenRepositoryProxy")
13+
allowInsecureProtocol true
14+
}
15+
}
16+
gradlePluginPortal()
317
mavenCentral()
418
}
519

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public boolean isModified(@Nonnull TestSourceData testSourceData) {
210210
.contains(sourcePath, lines.getStartLineNumber(), lines.getEndLineNumber());
211211

212212
} catch (Exception e) {
213-
LOGGER.error("Could not determine if {} was modified, assuming false", testSourceData, e);
213+
LOGGER.debug("Could not determine if {} was modified, assuming false", testSourceData, e);
214214
return false;
215215
}
216216
}

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/instrumentation/CodeOriginInstrumentor.java

+17-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
import static com.datadog.debugger.instrumentation.ASMHelper.ldc;
55
import static com.datadog.debugger.instrumentation.Types.DEBUGGER_CONTEXT_TYPE;
66
import static com.datadog.debugger.instrumentation.Types.STRING_TYPE;
7+
import static java.lang.Integer.parseInt;
78

89
import com.datadog.debugger.instrumentation.InstrumentationResult.Status;
10+
import com.datadog.debugger.probe.CodeOriginProbe;
911
import com.datadog.debugger.probe.ProbeDefinition;
1012
import datadog.trace.bootstrap.debugger.ProbeId;
1113
import java.util.List;
1214
import org.objectweb.asm.Type;
15+
import org.objectweb.asm.tree.AbstractInsnNode;
1316
import org.objectweb.asm.tree.InsnList;
17+
import org.objectweb.asm.tree.LabelNode;
1418

1519
public class CodeOriginInstrumentor extends Instrumentor {
1620
public CodeOriginInstrumentor(
@@ -26,11 +30,21 @@ public Status instrument() {
2630
InsnList insnList = new InsnList();
2731

2832
ldc(insnList, probeIds.get(0).getEncodedId());
29-
3033
invokeStatic(insnList, DEBUGGER_CONTEXT_TYPE, "codeOrigin", Type.VOID_TYPE, STRING_TYPE);
31-
32-
methodNode.instructions.insert(methodEnterLabel, insnList);
34+
methodNode.instructions.insert(findInsertionPoint(), insnList);
3335

3436
return InstrumentationResult.Status.INSTALLED;
3537
}
38+
39+
private AbstractInsnNode findInsertionPoint() {
40+
CodeOriginProbe probe = (CodeOriginProbe) definition;
41+
List<String> lines = probe.getLocation().getLines();
42+
if (!probe.entrySpanProbe() && lines != null && !lines.isEmpty()) {
43+
LabelNode lineLabel = classFileLines.getLineLabel(parseInt(lines.get(0)));
44+
if (lineLabel != null) {
45+
return lineLabel.getNext();
46+
}
47+
}
48+
return methodEnterLabel;
49+
}
3650
}

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/CodeOriginProbe.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ public boolean entrySpanProbe() {
8282
public void buildLocation(MethodInfo methodInfo) {
8383
String type = where.getTypeName();
8484
String method = where.getMethodName();
85-
List<String> lines = null;
85+
List<String> lines = where.getLines() != null ? asList(where.getLines()) : null;
8686

8787
String file = where.getSourceFile();
8888

8989
if (methodInfo != null) {
9090
type = methodInfo.getTypeName();
9191
method = methodInfo.getMethodName();
92-
if (methodInfo.getMethodStart() != -1) {
92+
if (entrySpanProbe || where.getLines() == null) {
9393
lines = singletonList(String.valueOf(methodInfo.getMethodStart()));
9494
}
9595
if (file == null) {

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/origin/CodeOriginTest.java

+17-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import static org.junit.jupiter.api.Assertions.assertNull;
1515
import static org.junit.jupiter.api.Assertions.assertTrue;
1616
import static utils.InstrumentationTestHelper.compileAndLoadClass;
17+
import static utils.InstrumentationTestHelper.getLineForLineProbe;
1718
import static utils.TestHelper.setFieldInConfig;
1819

1920
import com.datadog.debugger.agent.CapturingTestBase;
@@ -130,12 +131,25 @@ public void doubleEntry() throws IOException, URISyntaxException {
130131
final String className = "com.datadog.debugger.CodeOrigin05";
131132

132133
installProbes(
133-
new CodeOriginProbe(CODE_ORIGIN_ID1, true, Where.of(className, "entry", "()", "53"), true),
134-
new CodeOriginProbe(CODE_ORIGIN_ID2, false, Where.of(className, "exit", "()", "62"), true),
134+
new CodeOriginProbe(
135+
CODE_ORIGIN_ID1,
136+
true,
137+
Where.of(
138+
className, "entry", "()", "" + getLineForLineProbe(className, CODE_ORIGIN_ID1)),
139+
true),
140+
new CodeOriginProbe(
141+
CODE_ORIGIN_ID2,
142+
false,
143+
Where.of(className, "exit", "()", "" + getLineForLineProbe(className, CODE_ORIGIN_ID2)),
144+
true),
135145
new CodeOriginProbe(
136146
CODE_ORIGIN_DOUBLE_ENTRY_ID,
137147
true,
138-
Where.of(className, "doubleEntry", "()", "66"),
148+
Where.of(
149+
className,
150+
"doubleEntry",
151+
"()",
152+
"" + getLineForLineProbe(className, CODE_ORIGIN_DOUBLE_ENTRY_ID)),
139153
true));
140154
final Class<?> testClass = compileAndLoadClass(className);
141155
checkResults(testClass, "fullTrace", 0);

dd-java-agent/agent-debugger/src/test/resources/com/datadog/debugger/CodeOrigin05.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ private static AgentSpan newSpan(String name) {
4949

5050
public static void entry() throws NoSuchMethodException {
5151
// just to fill out the method body
52-
boolean dummyCode = true;
52+
boolean dummyCode = true; // code origin 1
5353
if (!dummyCode) {
5454
dummyCode = false;
5555
}
5656
doubleEntry();
5757
}
5858

5959
private static void exit() {
60-
int x = 47 / 3;
60+
int x = 47 / 3; // code origin 2
6161
}
6262

6363
public static void doubleEntry() throws NoSuchMethodException {
6464
// just to fill out the method body
6565
boolean dummyCode = true;
66-
if (!dummyCode) {
66+
if (!dummyCode) { // double entry code origin
6767
dummyCode = false;
6868
}
6969
}

0 commit comments

Comments
 (0)