无法在AWS EC2服务器上使用Golang PPROF的Web视图。

huangapple go评论82阅读模式
英文:

Unable to use the web view of Golang PPROF in AWS ec2 server

问题

我有一个用Golang开发的后端应用程序。我们遇到了内存泄漏的问题,所以我想使用pprof性能分析工具。我可以在终端中以交互模式访问该工具,但无法查看Web视图。

出现以下错误:

exec: "sensible-browser": 在$PATH中找不到可执行文件

我们在AWS EC2实例上运行我们的应用程序。请查看附件以查看错误。请帮助我,谢谢。

无法在AWS EC2服务器上使用Golang PPROF的Web视图。

英文:

I have backend application developed in Golang. We are facing memory leak issues, so I thought to use the pprof profiling tool. I could access the tool in interactive mode in terminal, but unable to view the webview.

Getting this error :

exec: "sensible-browser": executable file not found in $PATH

We are using AWS ec2 instance for our application. Please find the attachment to see the error. Please help me, Thanks in Advance.

无法在AWS EC2服务器上使用Golang PPROF的Web视图。

答案1

得分: 3

错误消息基本上是在说无法找到默认浏览器来查看您的 pprof 数据。

根据您执行 pprof 命令的位置(无法从截图中确定),您可以选择以下操作之一:
1)在可以设置默认浏览器的计算机上设置默认浏览器。详细信息请参见:https://askubuntu.com/a/16626/38168,但归根结底是要设置环境变量 BROWSER

export BROWSER=/usr/bin/firefox

或者,

2)如果您在某个远程 shell 上执行命令(无法使用浏览器),您可以生成一个 pprof dump(例如 cpu.prof),然后将其检索到您的桌面,并使用以下命令在浏览器中查看它:

go tool pprof -http=:8081 cpu.prof
英文:

The error message is basically saying that it is unable to find a default browser to view your pprof data.

Depending on where you are executing your pprof commands (cannot tell from the screenshot) you can either:

  1. set the default browser on a machine that can have one. See: https://askubuntu.com/a/16626/38168 for details but it boils down to having env variable BROWSER set:
export BROWSER=/usr/bin/firefox

or,

  1. if you're executing commands on some remote shell - where you cannot have a browser, you can just generate a pprof dump (e.g. cpu.prof) and then retrieve it to your desktop and view it in browser with a command:
go tool pprof -http=:8081 cpu.prof

huangapple
  • 本文由 发表于 2022年4月13日 01:02:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/71846626.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定