From ae6f6db045984b319b5f827f5cfbba7389ea01e3 Mon Sep 17 00:00:00 2001 From: jean-philippe bempel Date: Tue, 11 Feb 2025 14:33:37 +0100 Subject: [PATCH] Disable capture of entry values Due to overhead induced by capturing entry values because we need to freeze them (serialize as Json) immediately before even know if we are sampling it or not, compared to the usefulness of having those values we only capture at exit by default. (cherry picked from commit d5d15f107118f08b20f2084b208c5aa470efe61d) --- .../src/main/java/com/datadog/debugger/probe/LogProbe.java | 4 ++-- .../java/com/datadog/debugger/agent/CapturedSnapshotTest.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java index 95ba3426135..8342830403e 100644 --- a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java +++ b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java @@ -444,8 +444,8 @@ public Sampling getSampling() { @Override public InstrumentationResult.Status instrument( MethodInfo methodInfo, List diagnostics, List probeIds) { - // if evaluation is at exit and with condition, skip collecting data at entry - boolean captureEntry = !(getEvaluateAt() == MethodLocation.EXIT && hasCondition()); + // only capture entry values if explicitly not at Exit. By default, we are using evaluateAt=EXIT + boolean captureEntry = getEvaluateAt() != MethodLocation.EXIT; return new CapturedContextInstrumentor( this, methodInfo, diff --git a/dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturedSnapshotTest.java b/dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturedSnapshotTest.java index 228e847b8ce..e27b838cc20 100644 --- a/dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturedSnapshotTest.java +++ b/dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturedSnapshotTest.java @@ -155,7 +155,8 @@ public void methodProbeAtExit() throws IOException, URISyntaxException { int result = Reflect.onClass(testClass).call("main", "1").get(); assertEquals(3, result); Snapshot snapshot = assertOneSnapshot(listener); - assertCaptureArgs(snapshot.getCaptures().getEntry(), "arg", "java.lang.String", "1"); + // no entry values capture + assertEquals(CapturedContext.EMPTY_CAPTURING_CONTEXT, snapshot.getCaptures().getEntry()); assertCaptureArgs(snapshot.getCaptures().getReturn(), "arg", "java.lang.String", "1"); assertTrue(snapshot.getDuration() > 0); assertTrue(snapshot.getStack().size() > 0);