pyroscope 参考使用

时间:2021-03-05 13:17:19   收藏:0   阅读:0

基于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/

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!