1 Star 0 Fork 0

Lovnx/opentelemetry-java-instrumentation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
debugging.md 1.21 KB
一键复制 编辑 原始数据 按行查看 历史

Debugging

Debugging java agent can be a challenging task since some instrumentation code is directly inlined into target classes.

Advice methods

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()

Agent initialization code

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).

Enabling debugging

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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lovnx/opentelemetry-java-instrumentation.git
git@gitee.com:lovnx/opentelemetry-java-instrumentation.git
lovnx
opentelemetry-java-instrumentation
opentelemetry-java-instrumentation
main

搜索帮助