Route.Path() is "/"
I use the v2 example from README
package main
import (
"github.com/ansrivas/fiberprometheus/v2"
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New()
// This here will appear as a label, one can also use
// fiberprometheus.NewWith(servicename, namespace, subsystem )
// or
// NOTE: Following is not available in v1
// labels := map[string]string{"custom_label1":"custom_value1", "custom_label2":"custom_value2"}
// fiberprometheus.NewWithLabels(labels, namespace, subsystem )
prometheus := fiberprometheus.New("my-service-name")
prometheus.RegisterAt(app, "/metrics")
app.Use(prometheus.Middleware)
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello World")
})
app.Post("/some", func(c *fiber.Ctx) error {
return c.SendString("Welcome!")
})
app.Listen(":3000")
}
Calling both localhost:3000 and localhost:3000/some creates metrics with "/" path, while I expect to get two different paths "/" and "/some".
I added simple log to your middleware log.Printf("original url: %s, metrics path: %s", ctx.OriginalURL(), ctx.Route().Path), and this is the result:
2024/02/26 13:48:47 original url: /, metrics path: /
2024/02/26 13:48:52 original url: /some, metrics path: /
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.
@ansrivas This was fixed by #197 The middleware needs a new release.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 10 days with no activity.