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 e80b68f7881..e2959a90e53 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 @@ -553,9 +553,6 @@ public void commit(CapturedContext lineContext, int line) { if (status.shouldSend()) { snapshot.setTraceId(lineContext.getTraceId()); snapshot.setSpanId(lineContext.getSpanId()); - if (isCaptureSnapshot()) { - snapshot.addLine(lineContext, line); - } snapshot.setMessage(status.getMessage()); shouldCommit = true; } @@ -564,9 +561,12 @@ public void commit(CapturedContext lineContext, int line) { shouldCommit = true; } if (shouldCommit) { - // freeze context just before commit because line probes have only one context - Duration timeout = Duration.of(Config.get().getDebuggerCaptureTimeout(), ChronoUnit.MILLIS); - lineContext.freeze(new TimeoutChecker(timeout)); + if (isCaptureSnapshot()) { + // freeze context just before commit because line probes have only one context + Duration timeout = Duration.of(Config.get().getDebuggerCaptureTimeout(), ChronoUnit.MILLIS); + lineContext.freeze(new TimeoutChecker(timeout)); + snapshot.addLine(lineContext, line); + } commitSnapshot(snapshot, sink); return; }