跳到主要内容
版本:websocket_v1.x.x

Fgprof

Release Discord Test

为 Fiber 提供 fgprof 支持。

注意:需要 Go 1.19 或更高版本

安装

此中间件支持 Fiber v2。

使用 fgprof 来分析你的 Fiber 应用性能。

go get -u github.com/gofiber/fiber/v2
go get -u github.com/gofiber/contrib/fgprof

配置

属性类型描述默认值
下一页func(c *fiber.Ctx) bool当返回 true 时跳过此中间件的函数。nil
前缀string.Prefix 定义了一个添加到 "/debug/fgprof" 前面的 URL 前缀。注意它应该以斜杠开头(但不以斜杠结尾)。示例:"/federated-fiber"""

示例

package main

import (
"log"

"github.com/gofiber/contrib/fgprof"
"github.com/gofiber/fiber/v2"
)

func main() {
app := fiber.New()
app.Use(fgprof.New())
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("OK")
})
log.Fatal(app.Listen(":3000"))
}
go tool pprof -http=:8080 http://localhost:3000/debug/fgprof