Skip to content

Improve diagnostics for external agent attachment#1901

Open
codingkiddo wants to merge 1 commit intoraphw:masterfrom
codingkiddo:improve-agent-attachment-diagnostics-1602
Open

Improve diagnostics for external agent attachment#1901
codingkiddo wants to merge 1 commit intoraphw:masterfrom
codingkiddo:improve-agent-attachment-diagnostics-1602

Conversation

@codingkiddo
Copy link
Copy Markdown

Summary

Improves diagnostics for external Byte Buddy agent attachment.

When net.bytebuddy.agent.attacher.dump is configured, the generated external attachment command line is appended to the configured dump file before the external attacher process is started.

Motivation

Issue #1602 mentions that external attachment failures can be difficult to troubleshoot because users only see the final failure message. Including the generated command line in the existing dump output makes it easier to inspect the Java executable, classpath, attacher class, target VM type, process id, agent path, and native flag used for the external attachment attempt.

Changes

  • Refactors the external attachment process command into a List<String>
  • Appends the generated command line to the configured dump file
  • Keeps normal behavior unchanged when net.bytebuddy.agent.attacher.dump is not configured
  • Leaves the existing external process invocation behavior unchanged

Scope

This PR intentionally does not add support for extra JVM arguments or change attachment behavior. Those parts may require a separate design discussion.

Addresses part of #1602.

Testing

  • ./mvnw -pl byte-buddy-agent -am test
  • ./mvnw -pl byte-buddy-agent -am -DskipTests package
  • Ran a local reflection-based smoke test to invoke the external attachment path with net.bytebuddy.agent.attacher.dump=/tmp/byte-buddy-attacher.dump
  • Verified the dump file contains the generated external attachment command line before the attacher failure details
  • Verified an invalid dump path does not introduce a new failure in the external attachment flow
  • Verified no dump file is created when net.bytebuddy.agent.attacher.dump is not configured

Example verified dump content:

Byte Buddy external attachment command line:
/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home/jre/bin/java
-Dnet.bytebuddy.agent.attacher.dump=/tmp/byte-buddy-attacher.dump
-cp
...
net.bytebuddy.agent.Attacher
com.sun.tools.attach.VirtualMachine
...
false

Signed-off-by: Vinod Kumar <codingkiddo@gmail.com>
@codingkiddo codingkiddo force-pushed the improve-agent-attachment-diagnostics-1602 branch from 2da55ff to d1ab981 Compare May 8, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant