Skip to content

Commit 9b8eee7

Browse files
authored
Add method signature when report method not found (#8185)
1 parent 8bcee06 commit 9b8eee7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
*/
7474
public class DebuggerTransformer implements ClassFileTransformer {
7575
private static final Logger log = LoggerFactory.getLogger(DebuggerTransformer.class);
76-
private static final String CANNOT_FIND_METHOD = "Cannot find method %s::%s";
76+
private static final String CANNOT_FIND_METHOD = "Cannot find method %s::%s%s";
7777
private static final String INSTRUMENTATION_FAILS = "Instrumentation fails for %s";
7878
private static final String CANNOT_FIND_LINE = "No executable code was found at %s:L%s";
7979
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
@@ -536,20 +536,22 @@ private void handleInstrumentationResult(
536536
private void reportLocationNotFound(
537537
ProbeDefinition definition, String className, String methodName) {
538538
if (methodName != null) {
539-
reportErrorForAllProbes(singletonList(definition), CANNOT_FIND_METHOD, className, methodName);
539+
String signature = definition.getWhere().getSignature();
540+
signature = signature == null ? "" : signature;
541+
String msg = String.format(CANNOT_FIND_METHOD, className, methodName, signature);
542+
reportErrorForAllProbes(singletonList(definition), msg);
540543
return;
541544
}
542545
// This is a line probe, so we don't report line not found because the line may be found later
543546
// on a separate class files because probe was set on an inner/top-level class
544547
}
545548

546549
private void reportInstrumentationFails(List<ProbeDefinition> definitions, String className) {
547-
reportErrorForAllProbes(definitions, INSTRUMENTATION_FAILS, className, null);
550+
String msg = String.format(INSTRUMENTATION_FAILS, className);
551+
reportErrorForAllProbes(definitions, msg);
548552
}
549553

550-
private void reportErrorForAllProbes(
551-
List<ProbeDefinition> definitions, String format, String className, String location) {
552-
String msg = String.format(format, className, location);
554+
private void reportErrorForAllProbes(List<ProbeDefinition> definitions, String msg) {
553555
DiagnosticMessage diagnosticMessage = new DiagnosticMessage(DiagnosticMessage.Kind.ERROR, msg);
554556
for (ProbeDefinition definition : definitions) {
555557
addDiagnostics(definition, singletonList(diagnosticMessage));

0 commit comments

Comments
 (0)