尝试调用 Golang 跟踪时出错

问题描述 投票:0回答:2

以下命令可以很好地提供带有配置文件的网页,我能够对其进行分析,非常好。

go tool pprof -http=:8082 https://mytestserver.net:443/debug/pprof/profile?seconds=3

但是,如果我尝试跟踪,就会发生这种情况

$ go tool pprof -http=:8082 https://mytestserver.net:443/debug/pprof/trace?seconds=3
Fetching profile over HTTP from https://mytestserver.net:443/debug/pprof/trace?seconds=3
https://mytestserver.net:443/debug/pprof/trace?seconds=3: server response: 404 Not Found - Unknown profile
failed to fetch any source profiles

这也不行

$ go tool trace -http=:8082 https://mytestserver.net:443/debug/pprof/trace?seconds=3
2020/09/29 22:34:49 Parsing trace...
failed to open trace file: open https://mytestserver.net:443/debug/pprof/trace?seconds=3: The filename, directory name, or volume label syntax is incorrect.

正在关注一些例子 https://jvns.ca/blog/2017/09/24/profiling-go-with-pprof/

Trace 可用于可视化 GC 行为以及 Goroutine/Threads 等

还有其他方法可以生成trace吗?

我从 Windows 机器上运行跟踪,以下是版本控制信息

$ go version
go version go1.15.2 windows/amd64
go trace
2个回答
0
投票

您是否尝试过使用 http 而不是安全连接? 它似乎只适用于 FYR 的 http 连接。https://golang.org/pkg/net/http/pprof/


0
投票

这个问题有点老了,但至少在 Go 1.20 中我有同样的问题,因为

go tool trace
ONLY accepts files.

https://pkg.go.dev/net/http/pprof 文档也“暗示”了这一点,首先使用

curl
下载跟踪,然后使用
go tool trace

打开它
curl -o trace.out http://localhost:6060/debug/pprof/trace?seconds=5
go tool trace trace.out
© www.soinside.com 2019 - 2024. All rights reserved.