Go 调试

pprof

web

package main

import (
    "encoding/json"
    "fmt"
    "net/http"
    _ "net/http/pprof"
    "time"
)

func main() {
    go func() {
        for {
            fmt.Println(1111)
        }
    }()

    fmt.Println("start api server...")
    panic(http.ListenAndServe(":8080", nil))
}

使用生成火焰图

go tool pprof -http=:8081 -seconds 10  http://localhost:6060/debug/pprof/profile

http://127.0.0.1:8081/ui/flamegraph?si=cpu 查看cpu时长

参考

https://zhuanlan.zhihu.com/p/71529062

https://eddycjy.com/posts/go/tools/2018-09-15-go-tool-pprof/

prometheus metrics

posted @ 2020-11-15 11:01  walkingSun  阅读(155)  评论(0编辑  收藏  举报
**/