Skip to content

Commit 4004a3a

Browse files
authored
Merge branch 'master' into alejandro.gonzalez/issue-10494
2 parents 537a668 + b83178b commit 4004a3a

86 files changed

Lines changed: 3658 additions & 703 deletions

File tree

Some content is hidden

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

.gitlab/exploration-tests.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,25 @@ build-exploration-tests-image:
4444
- "*_surefire-reports.tar.gz"
4545
- "*_debugger-dumps.tar.gz"
4646

47-
# TODO fix them
48-
# exploration-tests-method-jsoup:
49-
# needs: [ build ]
50-
# dependencies:
51-
# - build
52-
# <<: *common-exploration-tests
53-
# variables:
54-
# PROJECT: jsoup
55-
# script:
56-
# - ./run-exploration-tests.sh "method" "$PROJECT" "mvn verify" "include_${PROJECT}.txt" "exclude_${PROJECT}.txt"
57-
#
58-
# exploration-tests-line-jsoup:
59-
# needs: [ build ]
60-
# dependencies:
61-
# - build
62-
# <<: *common-exploration-tests
63-
# variables:
64-
# PROJECT: jsoup
65-
# script:
66-
# - ./run-exploration-tests.sh "line" "$PROJECT" "mvn verify" "include_${PROJECT}.txt" "exclude_${PROJECT}.txt"
47+
exploration-tests-method-jsoup:
48+
needs: [ build ]
49+
dependencies:
50+
- build
51+
<<: *common-exploration-tests
52+
variables:
53+
PROJECT: jsoup
54+
script:
55+
- ./run-exploration-tests.sh "method" "$PROJECT" "mvn verify" "include_${PROJECT}.txt" "exclude_${PROJECT}.txt"
56+
57+
exploration-tests-line-jsoup:
58+
needs: [ build ]
59+
dependencies:
60+
- build
61+
<<: *common-exploration-tests
62+
variables:
63+
PROJECT: jsoup
64+
script:
65+
- ./run-exploration-tests.sh "line" "$PROJECT" "mvn verify" "include_${PROJECT}.txt" "exclude_${PROJECT}.txt"
6766

6867
exploration-tests-method-jackson-core:
6968
needs: [ build ]

BUILDING.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This documentation provides information for developers to set up their environme
1616

1717
### Quick check
1818

19-
To check that your development environment is properly set up to build the project, from the project root run on macOS or Linux:
19+
To check that your development environment is properly set up to build the project, run the following command from the project root on macOS or Linux:
2020
```shell
2121
./setup.sh
2222
```
@@ -54,40 +54,40 @@ If there is any issue with your output, check the requirements below and use the
5454

5555
Requirements to build the full project:
5656

57-
* A recent version (21+) of JDK,
58-
* The `git` command line must be installed,
59-
* A container runtime environment must be available to run all tests (e.g. Docker Desktop).
57+
* JDK version is 21+,
58+
* The `git` command line is installed,
59+
* A container runtime environment is available to run all tests (e.g. Docker Desktop).
6060

6161
### Install JDK
6262

6363
Java is required to run Gradle, the project build tool.
64-
Gradle will find any locally installed JDK and can download any missing JDK versions needed for the project build and testing.
64+
Gradle will find any locally installed JDK and download any missing JDK versions needed for the project build and testing.
6565

6666
#### macOS
6767

68-
Install a recent (21+) JDK using `brew`:
68+
Install JDK 21 using `brew`:
6969
```shell
7070
brew install --cask zulu@21
7171
```
7272

7373
#### Linux
7474

75-
Use your distribution package manager to install a recent (21+) JDK:
75+
Use your distribution package manager to install JDK 21:
7676
```shell
7777
apt install openjdk-21-jdk
7878
```
79-
Alternatively, manually download and install it from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/).
79+
Alternatively, manually download and install from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/).
8080

8181
Add the `JAVA_HOME` environment variable to your shell using the `export` command.
8282
You can permanently set it by appending the `export` command to your shell configuration file such as `~/.zshrc`, `~/.bashrc` or similar.
8383
```shell
8484
export JAVA_HOME=/<path to extracted archive>/jdk-21.x.x
8585
```
86-
Restart your shell after applying the changes if you appended the commands to your shell configuration file.
86+
If you appended the commands to your shell configuration file, restart your shell after applying the changes.
8787

8888
#### Windows
8989

90-
Install a recent (21+) JDK using the Windows package manager `winget`:
90+
Install JDK 21 using the Windows package manager `winget`:
9191
```pwsh
9292
winget install --id EclipseAdoptium.Temurin.21.JDK
9393
```
@@ -114,7 +114,7 @@ apt install git
114114

115115
#### Windows
116116

117-
Download and install the installer from [the official website](https://git-scm.com/download/win) or install it using the Windows package manager `winget`:
117+
Download and install the installer from [the official website](https://git-scm.com/download/win), or install it using the Windows package manager `winget`:
118118

119119
```pwsh
120120
winget install --id git.git
@@ -167,7 +167,7 @@ winget install --id Docker.DockerDesktop
167167
168168
> [!NOTE]
169169
> The git hooks will check that your code is properly formatted before committing.
170-
> This is done both to avoid future merge conflicts and ensure uniformity inside the code base.
170+
> This is done both to avoid future merge conflicts and ensure uniformity across the code base.
171171
172172
* Configure git to automatically update submodules.
173173
```shell
@@ -188,11 +188,11 @@ winget install --id Docker.DockerDesktop
188188
### Configure Akka Token
189189
> [!NOTE]
190190
> You can skip this step if you don’t need instrumentation for the **akka-http-10.6** module.
191-
> For background on why Akka now requires authentication, see this [article](https://akka.io/blog/why-we-are-changing-the-license-for-akka).
191+
> For background on why Akka now requires authentication, see [this article](https://akka.io/blog/why-we-are-changing-the-license-for-akka).
192192

193193
To enable access to Akka artifacts hosted on Lightbend’s private repository, you’ll need to configure an authentication token.
194-
1. Obtain a repository token. Visit the Akka account [page](https://account.akka.io/token) to generate a secure repository token.
195-
2. Set up the environment variable. Create an environment variable named:
194+
1. Obtain a repository token by visiting the Akka account [page](https://account.akka.io/token) to generate a secure repository token.
195+
2. Create an environment variable named:
196196
```shell
197197
ORG_GRADLE_PROJECT_akkaRepositoryToken=<your_token>
198198
```

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ Take a look at the [APM Glossary][visualization docs].
3535

3636
Before contributing to the project, please take a moment to read our brief [Contribution Guidelines](CONTRIBUTING.md).
3737
Then check our guides:
38-
* [How to setup a development and build the project](BUILDING.md),
38+
* [How to set up a development environment and build the project](BUILDING.md),
3939
* [How to create a new instrumentation](docs/add_new_instrumentation.md),
4040
* [How to test](docs/how_to_test.md),
4141

4242
Or our reference documents:
4343
* [How instrumentations work](docs/how_instrumentations_work.md).
4444

4545
## Releases
46-
Datadog will generally create a new minor release the first full week of every month.
46+
Datadog will generally release a new minor version during the first full week of every month.
4747

4848
See [release.md](docs/releases.md) for more information.

dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/CapturedContext.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ private CapturedContext(CapturedContext other, Map<String, Object> extensions) {
5353
this.arguments = other.arguments;
5454
this.locals = other.getLocals();
5555
this.throwable = other.throwable;
56+
this.staticFields = other.staticFields;
57+
this.limits = other.limits;
58+
this.thisClassName = other.thisClassName;
59+
this.duration = other.duration;
60+
this.captureExpressions = other.captureExpressions;
5661
this.extensions.putAll(other.extensions);
5762
this.extensions.putAll(extensions);
5863
}
@@ -177,6 +182,14 @@ private Object tryRetrieve(String name) {
177182
return result != null ? result : Values.UNDEFINED_OBJECT;
178183
}
179184

185+
public CapturedContext copyWithoutCaptureExpressions() {
186+
CapturedContext newContext = new CapturedContext(this, Collections.emptyMap());
187+
if (newContext.captureExpressions != null) {
188+
newContext.captureExpressions = null;
189+
}
190+
return newContext;
191+
}
192+
180193
@Override
181194
public ValueReferenceResolver withExtensions(Map<String, Object> extensions) {
182195
return new CapturedContext(this, extensions);

dd-java-agent/agent-debugger/exploration-tests/jackson-core_exploration-tests.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
diff --git a/pom.xml b/pom.xml
2+
index ae027596..5bbe70de 100644
3+
--- a/pom.xml
4+
+++ b/pom.xml
5+
@@ -8,7 +8,7 @@
6+
<parent>
7+
<groupId>com.fasterxml.jackson</groupId>
8+
<artifactId>jackson-base</artifactId>
9+
- <version>2.16.3-SNAPSHOT</version>
10+
+ <version>2.16.2</version>
11+
</parent>
12+
<groupId>com.fasterxml.jackson.core</groupId>
13+
<artifactId>jackson-core</artifactId>
114
diff --git a/src/test/java/com/fasterxml/jackson/core/json/async/AsyncConcurrencyTest.java b/src/test/java/com/fasterxml/jackson/core/json/async/AsyncConcurrencyTest.java
215
index 2f7957d1..7a8ea388 100644
316
--- a/src/test/java/com/fasterxml/jackson/core/json/async/AsyncConcurrencyTest.java

dd-java-agent/agent-debugger/exploration-tests/jackson-databind_exploration-tests.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
diff --git a/pom.xml b/pom.xml
2+
index 7c1510841..c539f5978 100644
3+
--- a/pom.xml
4+
+++ b/pom.xml
5+
@@ -9,7 +9,7 @@
6+
<parent>
7+
<groupId>com.fasterxml.jackson</groupId>
8+
<artifactId>jackson-base</artifactId>
9+
- <version>2.16.3-SNAPSHOT</version>
10+
+ <version>2.16.2</version>
11+
</parent>
12+
<groupId>com.fasterxml.jackson.core</groupId>
13+
<artifactId>jackson-databind</artifactId>
114
diff --git forkSrcPrefix/src/test/java/com/fasterxml/jackson/databind/misc/ThreadSafety1759Test.java forkDstPrefix/src/test/java/com/fasterxml/jackson/databind/misc/ThreadSafety1759Test.java
215
index 68c52b600550268242d16614e6143104ce37961d..29f453c8c0e07d139edd095d1614dd287aa5d283 100644
316
--- forkSrcPrefix/src/test/java/com/fasterxml/jackson/databind/misc/ThreadSafety1759Test.java

dd-java-agent/agent-debugger/exploration-tests/jsoup_exploration-tests.patch

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
1+
diff --git a/src/test/java/org/jsoup/integration/ProxyTest.java b/src/test/java/org/jsoup/integration/ProxyTest.java
2+
index 18c1a60b..b79d5ee7 100644
3+
--- a/src/test/java/org/jsoup/integration/ProxyTest.java
4+
+++ b/src/test/java/org/jsoup/integration/ProxyTest.java
5+
@@ -12,6 +12,7 @@ import org.jsoup.nodes.Document;
6+
import org.jsoup.nodes.Element;
7+
import org.junit.jupiter.api.BeforeAll;
8+
import org.junit.jupiter.api.Test;
9+
+import org.junit.jupiter.api.Disabled;
10+
import org.junit.jupiter.params.ParameterizedTest;
11+
import org.junit.jupiter.params.provider.MethodSource;
12+
13+
@@ -26,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.*;
14+
15+
/**
16+
Tests Jsoup.connect proxy support */
17+
+@Disabled
18+
public class ProxyTest {
19+
private static String echoUrl;
20+
private static TestServer.ProxySettings proxy;
121
diff --git a/src/test/java/org/jsoup/parser/HtmlParserTest.java b/src/test/java/org/jsoup/parser/HtmlParserTest.java
222
index a67003a8..1201d1af 100644
323
--- a/src/test/java/org/jsoup/parser/HtmlParserTest.java
424
+++ b/src/test/java/org/jsoup/parser/HtmlParserTest.java
525
@@ -1033,7 +1033,7 @@ public class HtmlParserTest {
6-
26+
727
// Assert
828
assertEquals(50000, doc.body().childNodeSize());
929
- assertTrue(System.currentTimeMillis() - start < 1000);
1030
+ //assertTrue(System.currentTimeMillis() - start < 10000);
1131
}
12-
32+
1333
@Test
1434
diff --git a/src/test/java/org/jsoup/parser/ParserIT.java b/src/test/java/org/jsoup/parser/ParserIT.java
1535
index 54d757e7..467c10bc 100644

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerTransformer.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ private static ProbeDefinition selectReferenceDefinition(
781781
LogProbe.Capture capture = null;
782782
boolean captureSnapshot = false;
783783
ProbeCondition probeCondition = null;
784+
List<LogProbe.CaptureExpression> captureExpressions = null;
784785
Where where = capturedContextProbes.get(0).getWhere();
785786
ProbeId probeId = capturedContextProbes.get(0).getProbeId();
786787
for (ProbeDefinition definition : capturedContextProbes) {
@@ -792,6 +793,8 @@ private static ProbeDefinition selectReferenceDefinition(
792793
LogProbe logProbe = (LogProbe) definition;
793794
captureSnapshot = captureSnapshot | logProbe.isCaptureSnapshot();
794795
capture = mergeCapture(capture, logProbe.getCapture());
796+
// captureExpressions = mergeCaptureExpressions(captureExpressions,
797+
// logProbe.getCaptureExpressions());
795798
if (probeCondition == null) {
796799
probeCondition = logProbe.getProbeCondition();
797800
}
@@ -837,6 +840,19 @@ private static LogProbe.Capture mergeCapture(
837840
Math.max(current.getMaxFieldCount(), newCapture.getMaxFieldCount()));
838841
}
839842

843+
private static List<LogProbe.CaptureExpression> mergeCaptureExpressions(
844+
List<LogProbe.CaptureExpression> captureExpressions,
845+
List<LogProbe.CaptureExpression> newCaptureExpressions) {
846+
if (captureExpressions == null) {
847+
return newCaptureExpressions;
848+
}
849+
if (newCaptureExpressions == null) {
850+
return captureExpressions;
851+
}
852+
captureExpressions.addAll(newCaptureExpressions);
853+
return captureExpressions;
854+
}
855+
840856
private InstrumentationResult.Status preCheckInstrumentation(
841857
Map<ProbeId, List<DiagnosticMessage>> diagnostics, MethodInfo methodInfo) {
842858
if ((methodInfo.getMethodNode().access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) != 0) {

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,7 @@ protected boolean fillSnapshot(
636636
snapshot.setTraceId(CorrelationIdentifier.getTraceId());
637637
snapshot.setSpanId(CorrelationIdentifier.getSpanId());
638638
if (isFullSnapshot()) {
639-
snapshot.setEntry(entryContext);
640-
snapshot.setExit(exitContext);
639+
assignCaptures(snapshot, entryContext, exitContext);
641640
}
642641
snapshot.setMessage(message);
643642
snapshot.setDuration(exitContext.getDuration());
@@ -655,6 +654,41 @@ protected boolean fillSnapshot(
655654
return shouldCommit;
656655
}
657656

657+
private void assignCaptures(
658+
Snapshot snapshot, CapturedContext entryContext, CapturedContext exitContext) {
659+
if (isCaptureSnapshot()) {
660+
addContextWithoutCaptureExpressions(entryContext, snapshot::setEntry);
661+
addContextWithoutCaptureExpressions(exitContext, snapshot::setExit);
662+
} else if (captureExpressions != null) {
663+
addFilteredCaptureExpressions(entryContext, snapshot::setEntry);
664+
addFilteredCaptureExpressions(exitContext, snapshot::setExit);
665+
}
666+
}
667+
668+
private void addContextWithoutCaptureExpressions(
669+
CapturedContext context, Consumer<CapturedContext> setContext) {
670+
// no capture expressions, assign directly the context in the snapshot
671+
if (context.getCaptureExpressions() == null || context.getCaptureExpressions().isEmpty()) {
672+
setContext.accept(context);
673+
return;
674+
}
675+
CapturedContext newContext = context.copyWithoutCaptureExpressions();
676+
setContext.accept(newContext);
677+
}
678+
679+
private void addFilteredCaptureExpressions(
680+
CapturedContext capturedContext, Consumer<CapturedContext> setContext) {
681+
Map<String, CapturedContext.CapturedValue> contextCapExpr =
682+
capturedContext.getCaptureExpressions();
683+
if (contextCapExpr != null && !contextCapExpr.isEmpty()) {
684+
CapturedContext newContext = new CapturedContext();
685+
for (CaptureExpression capExprDef : captureExpressions) {
686+
newContext.addCaptureExpression(contextCapExpr.get(capExprDef.getName()));
687+
}
688+
setContext.accept(newContext);
689+
}
690+
}
691+
658692
private void processCaptureExpressions(CapturedContext context, LogStatus logStatus) {
659693
if (captureExpressions == null) {
660694
return;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import datadog.trace.bootstrap.debugger.MethodLocation;
1919
import datadog.trace.bootstrap.debugger.ProbeId;
2020
import datadog.trace.bootstrap.debugger.ProbeImplementation;
21+
import datadog.trace.bootstrap.debugger.ProbeRateLimiter;
2122
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
2223
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
2324
import datadog.trace.util.TagsHelper;
@@ -294,6 +295,10 @@ private void handleEvaluationErrors(SpanDecorationStatus status) {
294295
if (status.getErrors().isEmpty()) {
295296
return;
296297
}
298+
boolean sampled = ProbeRateLimiter.tryProbe(id);
299+
if (!sampled) {
300+
return;
301+
}
297302
Snapshot snapshot = new Snapshot(Thread.currentThread(), this, -1);
298303
snapshot.addEvaluationErrors(status.getErrors());
299304
DebuggerAgent.getSink().addSnapshot(snapshot);

0 commit comments

Comments
 (0)