Debugging java agent can be a challenging task since some instrumentation code is directly inlined into target classes.
Breakpoints do not work in advice methods, because their code is directly inlined by ByteBuddy into the target class. It is good to keep these methods as small as possible. The advice methods are annotated with:
@net.bytebuddy.asm.Advice.OnMethodEnter
@net.bytebuddy.asm.Advice.OnMethodExit
The best approach to debug advice methods and agent initialization is to use the following statements:
System.out.println()
Thread.dumpStack()
If you want to debug agent initialization code (e.g. OpenTelemetryAgent
, AgentInitializer
,
AgentInstaller
, OpenTelemetryInstaller
, etc.) then it's important to specify the -agentlib:
JVM arg
before the -javaagent:
JVM arg and use suspend=y
(see full example below).
The following example shows remote debugger configuration. The breakpoints should work in any code except ByteBuddy advice methods.
java -agentlib:jdwp="transport=dt_socket,server=y,suspend=y,address=5000" -javaagent:opentelemetry-javaagent-<version>-all.jar -jar app.jar
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。