You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, I'm working on observability (o11y) and need to metric the current API path to track API performance.
In Prometheus' recommendations, it's mentioned that labels should ideally have a static string;
if labels are dynamic, performance may degrade.
However, when I use fiber middleware, I'm unable to obtain the expected path.
When I use c.Route().Path, I expect to get /users/:id, but I keep getting /.
When I use c.Path(), I can get the correct path /users/123, but it doesn't meet Prometheus' requirement for static labels.
How to Reproduce
Steps to reproduce the behavior:
setup middleware and get c.Route().Path
Expected Behavior
expected path should be /users/:id
Fiber Version
v2.52.5
Code Snippet (optional)
router:=fiber.New()
prometheusMiddleware:=func(c*fiber.Ctx) error {
path1:=c.Path()
path2:=c.Route().Pathlog.Printf("path1=%v path2=%v in prometheus middleware\n", path1, path2)
returnc.Next()
}
router.Use(prometheusMiddleware)
userHandler:=func(c*fiber.Ctx) error {
path1:=c.Path()
path2:=c.Route().Pathlog.Printf("path1=%v path2=%v in user handler\n", path1, path2)
returnc.SendString("User ID: "+c.Params("id"))
}
router.Get("/users/:id", userHandler)
req:=httptest.NewRequest(http.MethodGet, "/users/123", nil)
router.Test(req)
// 2024/09/18 14:42:27 path1=/users/123 path2=/ in prometheus middleware// 2024/09/18 14:42:27 path1=/users/123 path2=/users/:id in user handler
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
Bug Description
Currently, I'm working on observability (o11y) and need to metric the current API path to track API performance.
In Prometheus' recommendations, it's mentioned that labels should ideally have a static string;
if labels are dynamic, performance may degrade.
However, when I use fiber middleware, I'm unable to obtain the expected path.
When I use
c.Route().Path
, I expect to get/users/:id
, but I keep getting/
.When I use
c.Path()
, I can get the correct path/users/123
, but it doesn't meet Prometheus' requirement for static labels.How to Reproduce
Steps to reproduce the behavior:
c.Route().Path
Expected Behavior
expected path should be
/users/:id
Fiber Version
v2.52.5
Code Snippet (optional)
playground
Checklist:
The text was updated successfully, but these errors were encountered: