基于golang 运行
运行server
brew install pyroscope-io/brew/pyroscope
pyroscope server
golang 代码
package main
import (
"github.com/gin-gonic/gin"
"github.com/pyroscope-io/pyroscope/pkg/agent/profiler"
)
func main() {
profiler.Start(profiler.Config{
ApplicationName: "backend.purchases",
ServerAddress: "http://localhost:4040",
})
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
负载
#!/bin/sh
while true
do
curl -i http://localhost:8080/ping
sleep 0.1
done
效果
参考资料
https://github.com/pyroscope-io/pyroscope
https://pyroscope.io/docs/