天天看点

Pinpoint本地调试

如何本地调试

这里的本地调试实际上是本地远程debug,除了需要pinpoint源码,还需要一个使用我们编译后的pinpoint agent的应用

  • 执行命令

    ./mvnw install -DskipTests=true

    编译好agent jar包放到特定目录
  • 在应用中配置需要agent参数,同时配置debug参数,如下
-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -javaagent:"/Users/lpchou/Documents/pinpoint-agent-2.0.3-SNAPSHOT/pinpoint-bootstrap-2.0.3-SNAPSHOT.jar" -Dspring.profiles.active=dev -Dpinpoint.agentId=yanxuan-owl-web -Dpinpoint.applicationName=owlWeb
           

这里的agent路径以及agentId和applicationName需要对应替换下

  • 在pinpoint源码工程中新增一个 Remote,参数为

    -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

    (一般会自己有),如下所示
    Pinpoint本地调试
  • run而不是debug刚刚添加了agent的应用,此时输出如下,在监听端口
    Pinpoint本地调试
  • debug pinpoint项目,这时便可以添加断点调试了
    Pinpoint本地调试
    调试界面如下
    Pinpoint本地调试

插件太多,只调试部分插件

在我们自己重新编译调试的时候,pinpoint的插件太多了,对于调试起来也有点麻烦,这时我们可以先注释掉大部分插件,再重新编译,只调试我们关注的插件。

  • 在plugins下的assembly模块的pom.xml中去掉不想编译的插件,这样生成的agent里便没有不需要的插件jar

执行命令

./mvnw install -DskipTests=true

耐心等待编译完后,生成的target下的plugin里便只有我们需要的插件包了

注意不要注释掉 mongo的插件依赖,因为web模块里依赖了这个插件包下的类

MongoConstants

,如果去掉编译时会报如下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project pinpoint-web: Compilation failure: Compilation failure: 
[ERROR] /Users/lpchou/IdeaProjects/pinpoint/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java:[35,42] 错误: 程序包com.navercorp.pinpoint.plugin.mongo不存在
[ERROR] /Users/lpchou/IdeaProjects/pinpoint/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java:[210,93] 错误: 程序包MongoConstants不存在
[ERROR] /Users/lpchou/IdeaProjects/pinpoint/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java:[211,95] 错误: 程序包MongoConstants不存在
[ERROR] /Users/lpchou/IdeaProjects/pinpoint/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java:[226,93] 错误: 程序包MongoConstants不存在
[ERROR] /Users/lpchou/IdeaProjects/pinpoint/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java:[239,75] 错误: 程序包MongoConstants不存在
[ERROR] /Users/lpchou/IdeaProjects/pinpoint/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java:[244,86] 错误: 程序包MongoConstants不存在
[ERROR] -> [Help 1]