Skip to content

Commit 7e67a2e

Browse files
committed
Only capture stacktrace for snapshot probes
For any log probes we recorded stacktrace while this is useless and wasteful for template log only
1 parent a481d0b commit 7e67a2e

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,9 @@ protected void commitSnapshot(Snapshot snapshot, DebuggerSink sink) {
530530
* - ProbeDefinition.commit()
531531
* - DebuggerContext.commit() or DebuggerContext.evalAndCommit()
532532
*/
533-
snapshot.recordStackTrace(5);
533+
if (isCaptureSnapshot()) {
534+
snapshot.recordStackTrace(5);
535+
}
534536
sink.addSnapshot(snapshot);
535537
}
536538

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/LogProbesInstrumentationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.junit.jupiter.api.Assertions.assertEquals;
55
import static org.junit.jupiter.api.Assertions.assertNotNull;
66
import static org.junit.jupiter.api.Assertions.assertNull;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
78
import static org.mockito.Mockito.mock;
89
import static org.mockito.Mockito.when;
910
import static utils.InstrumentationTestHelper.compileAndLoadClass;
@@ -63,6 +64,7 @@ public void methodPlainLog() throws IOException, URISyntaxException {
6364
Assertions.assertEquals(3, result);
6465
Snapshot snapshot = assertOneSnapshot(listener);
6566
assertCapturesNull(snapshot);
67+
assertTrue(snapshot.getStack().isEmpty());
6668
assertEquals("this is log line", snapshot.getMessage());
6769
}
6870

0 commit comments

Comments
 (0)