Skip to content

Commit 797aca9

Browse files
committed
dropped snapshots from CO probes
1 parent 66af130 commit 797aca9

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ private boolean instrumentationIsAllowed(
409409
return true;
410410
}
411411

412-
private ClassNode parseClassFile(String classFilePath, byte[] classfileBuffer) {
412+
public ClassNode parseClassFile(String classFilePath, byte[] classfileBuffer) {
413413
ClassReader reader = new ClassReader(classfileBuffer);
414414
dumpOriginalClassFile(classFilePath, classfileBuffer);
415415
ClassNode classNode = new ClassNode();

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/codeorigin/DefaultCodeOriginRecorder.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.datadog.debugger.probe.CodeOriginProbe;
88
import com.datadog.debugger.probe.Where;
99
import datadog.trace.api.Config;
10-
import datadog.trace.bootstrap.debugger.CapturedContext;
1110
import datadog.trace.bootstrap.debugger.DebuggerContext;
1211
import datadog.trace.bootstrap.debugger.DebuggerContext.CodeOriginRecorder;
1312
import datadog.trace.bootstrap.debugger.ProbeId;
@@ -17,7 +16,6 @@
1716
import datadog.trace.util.stacktrace.StackWalkerFactory;
1817
import java.lang.reflect.Method;
1918
import java.util.Collection;
20-
import java.util.Collections;
2119
import java.util.HashMap;
2220
import java.util.Map;
2321
import java.util.UUID;
@@ -81,8 +79,9 @@ private CodeOriginProbe createProbe(String fingerPrint, boolean entry, Where whe
8179
// committing here manually so that first run probe encounters decorate the span until the
8280
// instrumentation gets installed
8381
if (span != null) {
84-
probe.commit(
85-
CapturedContext.EMPTY_CONTEXT, CapturedContext.EMPTY_CONTEXT, Collections.emptyList());
82+
// probe.commit(
83+
// CapturedContext.EMPTY_CONTEXT, CapturedContext.EMPTY_CONTEXT,
84+
// Collections.emptyList());
8685
}
8786
return probe;
8887
}

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/instrumentation/InstrumentationResult.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.HashMap;
88
import java.util.List;
99
import java.util.Map;
10+
import org.objectweb.asm.tree.MethodNode;
1011

1112
/** Stores status instrumentation results */
1213
public class InstrumentationResult {
@@ -67,9 +68,10 @@ public InstrumentationResult(
6768
this.diagnostics = diagnostics;
6869
this.sourceFileName = methodInfo.getClassNode().sourceFile;
6970
this.typeName = methodInfo.getClassNode().name.replace('/', '.');
70-
this.methodName = methodInfo.getMethodNode().name;
71-
this.signature = methodInfo.getMethodNode().signature;
71+
MethodNode methodNode = methodInfo.getMethodNode();
72+
this.methodName = methodNode.name;
7273
this.methodStart = methodInfo.getMethodStart();
74+
this.signature = Types.descriptorToSignature(methodNode.desc);
7375
}
7476

7577
public boolean isError() {

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.datadog.debugger.probe;
22

3+
import static com.datadog.debugger.probe.LogProbe.Capture.toLimits;
34
import static datadog.trace.api.DDTags.DD_CODE_ORIGIN_FRAME;
45
import static datadog.trace.api.DDTags.DD_CODE_ORIGIN_TYPE;
56
import static java.lang.String.format;
67
import static java.util.Arrays.asList;
78
import static java.util.Collections.singletonList;
89

10+
import com.datadog.debugger.instrumentation.CapturedContextInstrumentor;
11+
import com.datadog.debugger.instrumentation.DiagnosticMessage;
912
import com.datadog.debugger.instrumentation.InstrumentationResult;
13+
import com.datadog.debugger.instrumentation.MethodInfo;
1014
import datadog.trace.bootstrap.debugger.CapturedContext;
1115
import datadog.trace.bootstrap.debugger.CapturedContext.CapturedThrowable;
1216
import datadog.trace.bootstrap.debugger.MethodLocation;
@@ -23,11 +27,21 @@ public class CodeOriginProbe extends LogProbe implements ForceMethodInstrumentat
2327

2428
private final boolean entrySpanProbe;
2529

30+
private String signature;
31+
2632
public CodeOriginProbe(ProbeId probeId, boolean entry, Where where) {
2733
super(LANGUAGE, probeId, null, where, MethodLocation.EXIT, null, null, true, null, null, null);
2834
this.entrySpanProbe = entry;
2935
}
3036

37+
@Override
38+
public InstrumentationResult.Status instrument(
39+
MethodInfo methodInfo, List<DiagnosticMessage> diagnostics, List<ProbeId> probeIds) {
40+
return new CapturedContextInstrumentor(
41+
this, methodInfo, diagnostics, probeIds, isCaptureSnapshot(), toLimits(null))
42+
.instrument();
43+
}
44+
3145
@Override
3246
public boolean isLineProbe() {
3347
// these are always method probes even if there is a line number
@@ -56,9 +70,9 @@ private void recordCodeOrigin() {
5670
int i = 0;
5771
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "file"), location.getFile());
5872
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "method"), location.getMethod());
59-
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "line"), "-1");
73+
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "line"), location.getLines().get(0));
6074
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "type"), location.getType());
61-
// s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "signature"), signature);
75+
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "signature"), signature);
6276
}
6377
}
6478

@@ -83,6 +97,7 @@ public void buildLocation(InstrumentationResult result) {
8397
if (file == null) {
8498
file = result.getSourceFileName();
8599
}
100+
signature = result.getMethodSignature();
86101
}
87102
this.location = new ProbeLocation(type, method, file, lines);
88103
}

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/origin/CodeOriginTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void withLogProbe() throws IOException, URISyntaxException {
118118
} catch (InterruptedException e) {
119119
throw new RuntimeException(e);
120120
}
121-
checkResults(testClass, "debug_1", true);
121+
checkResults(testClass, "debug_1", false);
122122
}
123123

124124
@Test

0 commit comments

Comments
 (0)