Skip to content

Commit 844be15

Browse files
committed
Add Capture Expressions
Previously watches, capture expressions allow to describe what exactly we want to capture and put into a snapshot for a log probe. When one or more capture expressions is defined, only the capture expressions are added to the Captures part of the snapshot. Expressions can be complex using the expression language and must return a value from which we start to capture the object graph following the limits that can be defined per capture expressions. A new attribute captureExpressions is added into the snapshot.
1 parent 60a3b9d commit 844be15

File tree

12 files changed

+329
-129
lines changed

12 files changed

+329
-129
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class CapturedContext implements ValueReferenceResolver {
3434
private String thisClassName;
3535
private long duration;
3636
private final Map<String, Status> statusByProbeId = new LinkedHashMap<>();
37-
private Map<String, CapturedValue> watches;
37+
private Map<String, CapturedValue> captureExpressions;
3838

3939
public CapturedContext() {}
4040

@@ -260,8 +260,8 @@ public Map<String, CapturedValue> getStaticFields() {
260260
return staticFields;
261261
}
262262

263-
public Map<String, CapturedValue> getWatches() {
264-
return watches;
263+
public Map<String, CapturedValue> getCaptureExpressions() {
264+
return captureExpressions;
265265
}
266266

267267
public Limits getLimits() {
@@ -277,9 +277,9 @@ public String getThisClassName() {
277277
* instance representation into the corresponding string value.
278278
*/
279279
public void freeze(TimeoutChecker timeoutChecker) {
280-
if (watches != null) {
281-
// freeze only watches
282-
watches.values().forEach(capturedValue -> capturedValue.freeze(timeoutChecker));
280+
if (captureExpressions != null) {
281+
// freeze only capture expressions
282+
captureExpressions.values().forEach(capturedValue -> capturedValue.freeze(timeoutChecker));
283283
return;
284284
}
285285
if (arguments != null) {
@@ -377,11 +377,11 @@ private void putInStaticFields(String name, CapturedValue value) {
377377
staticFields.put(name, value);
378378
}
379379

380-
public void addWatch(CapturedValue value) {
381-
if (watches == null) {
382-
watches = new HashMap<>();
380+
public void addCaptureExpression(CapturedValue value) {
381+
if (captureExpressions == null) {
382+
captureExpressions = new HashMap<>();
383383
}
384-
watches.put(value.name, value);
384+
captureExpressions.put(value.name, value);
385385
}
386386

387387
public static class Status {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public ExceptionProbe(
4646
// forcing a useless condition to be instrumented with captureEntry=false
4747
new ProbeCondition(DSL.when(DSL.TRUE), "true"),
4848
capture,
49-
sampling);
49+
sampling,
50+
null);
5051
this.exceptionProbeManager = exceptionProbeManager;
5152
this.chainedExceptionIdx = chainedExceptionIdx;
5253
}

0 commit comments

Comments
 (0)