一个在 production 环境运行的进程,不可能修改代码,日志记录的也不详细,不定时出现某个函数执行慢的情况,gops,pprof 等都需要在代码中实现 agent 才能 profiling 和 tracing 。有没有大佬了解有什么工具可以不需要 agent 跟踪正在运行的程序的堆栈调用?
1
JeromeCui Oct 23, 2020
我就会一招:打印日志
|
3
lcode Oct 23, 2020
测试环境模拟一下
不能复现的 bug 就不是 bug ( |
4
zunceng Oct 23, 2020 http 框架里面集成一个 pprof 中间件 做好了以后一行代码就好了 如果是 gin 直接用下面的
https://github.com/gin-contrib/pprof |
5
monsterxx03 Oct 23, 2020
|
6
polythene Oct 23, 2020
Linux 下的 perf 能直接读取 Go 进程的符号值
|
7
TypeErrorNone Oct 23, 2020
@zunceng 如果有几十个容器,怎么搞呢
|
8
Adriel Oct 23, 2020
|
9
kiddingU Oct 23, 2020
opentracing 可以定位到是链路中哪个函数慢,然后再去优化
|
10
Lonenso Oct 23, 2020 via Android
|
11
Leigg Oct 23, 2020 via Android
你不能确定函数范围?没上链路追踪就自己挨个打日志
|
12
zunceng Oct 23, 2020
@TypeErrorNone 一般来说不会把这个接口暴露出去 想个办法内部访问
如果程序部署在 k8s kubectl run my-shell --rm -i --tty --image golang -- sh > go tools pprof http://${pod_name}/debug/pprof/heap 在生产创建 pod 的权限非常高 对权限管控有要求的企业 可以把这一套做成一个线上的调试工具 web 方式提供给内部人员使用 |