Go statsviz 是一个支持在浏览器中可视化 Go 程序运行时指标的实时图表,包括堆、对象、goroutines、GC 暂停、调度器等指标
使用
- 支持与 echo、fasthttp、fiber、gin 等集成,参考
- Supported metrics
- 支持的图表(不同 go 版本会有不同):
- Heap (global)
- Heap (details)
- Live Objects in Heap
- Live Bytes in Heap
- MSpan/MCache
- Memory classes
- Goroutines
- Size Classes
- GC Scan
- GC Cycles
- Stop-the-world Pause Latencies
- CPU Classes (GC)
- Time Goroutines Spend in ‘Runnable’ state
- Time Goroutines Spend Blocked on Mutexes
- Starting Size of Goroutines Stacks
- Goroutine Scheduling Events
- CGO Calls
package main
import (
"fmt"
"log"
"net/http"
"github.com/arl/statsviz"
example "github.com/arl/statsviz/_example"
)
func main() {
// Force the GC to work to make the plots "move".
go example.Work()
// Register a Statsviz server on the default mux.
statsviz.Register(http.DefaultServeMux)
fmt.Println("Point your browser to http://localhost:8080/debug/statsviz/")
log.Fatal(http.ListenAndServe(":8080", nil))
}
- 启动,服务监听在 http://localhost:8080/debug/statsviz
go run main.go