feat: prometheus

This commit is contained in:
2025-12-14 14:11:33 +08:00
parent 31b9fb5d45
commit a9d2f05562
10 changed files with 162 additions and 132 deletions

View File

@@ -0,0 +1,21 @@
package middleware
import (
"nysoure/server/stat"
"github.com/gofiber/fiber/v3"
)
func StatMiddleware(c fiber.Ctx) error {
err := c.Next()
status := "200"
if err != nil {
if e, ok := err.(*fiber.Error); ok {
status = string(rune(e.Code))
} else {
status = "500"
}
}
stat.RecordRequest(c.Method(), c.Path(), status)
return err
}