社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
docker run -it -p 4040:4040 pyroscope/pyroscope:latest server
启动后浏览器打开:localhost:4040 即可访问
import "github.com/pyroscope-io/pyroscope/pkg/agent/profiler"
// 在项目里入以下代码即可
profiler.Start(profiler.Config{
ApplicationName: "simple.golang.app",
ServerAddress: "http://localhost:4040",
})
如:
package main
import (
"fmt"
"time"
"github.com/pyroscope-io/pyroscope/pkg/agent/profiler"
)
// go get -u github.com/pyroscope-io/pyroscope/pkg/agent/profiler
// Pyroscope 是一套开源的效能即时监控平台,简单的Server 及Agent 架构,让开发者可以轻松监控代码效能,不管你要找10 秒或几分钟内的效能数据,都可以快速的即时呈现,
//开发者也不用在意装了此监控会造成任何效能上的负担。
//Pyroscope 背后的储存采用 目前只有支援3 种语言(Python, Ruby 及Go) 未来会 假设您还没导入任何效能分析工具或平台,那Pyroscope 会是您最好的选择。
func main() {
profiler.Start(profiler.Config{
ApplicationName: "simple.golang.app",
ServerAddress: "http://localhost:4040",
})
for i := 0; i < 10; i++ {
time.Sleep(time.Second * time.Duration(i))
fmt.Println(i)
}
}
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!