Skip to content

Commit 485ef50

Browse files
authored
Only capture stacktrace for snapshot probes (#6955)
For any log probes we recorded stacktrace while this is useless and wasteful for template log only
1 parent 154b90a commit 485ef50

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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
@@ -534,7 +534,9 @@ protected void commitSnapshot(Snapshot snapshot, DebuggerSink sink) {
534534
* - ProbeDefinition.commit()
535535
* - DebuggerContext.commit() or DebuggerContext.evalAndCommit()
536536
*/
537-
snapshot.recordStackTrace(5);
537+
if (isCaptureSnapshot()) {
538+
snapshot.recordStackTrace(5);
539+
}
538540
sink.addSnapshot(snapshot);
539541
}
540542

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)