-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incorrect path when using groups #187
Comments
Hey @FedeBev, thanks for reporting this. prometheus := fiberprometheus.New("my-service-name")
public := app.Group("/public") // Here declared the Group before calling RegisterAt and app.Use
prometheus.RegisterAt(app, "/metrics")
app.Use(prometheus.Middleware)
public.Get("/somepath", func(c *fiber.Ctx) error {
return c.SendString("Hello World from somepath")
}) And corresponding to that, I can see the following:
|
Interesting, I tried your suggestion but I'm still seeing the same app := fiber.New()
public := app.Group("/public")
admin := app.Group("/admin")
prometheus := fiberprometheus.NewWithLabels(labels, strings.ReplaceAll(Component, "-", "_"), "http")
prometheus.RegisterAt(app, "/metrics")
app.Use(prometheus.Middleware)
public.Get("/somepath", func(c *fiber.Ctx) error {
...
})
|
This is certainly strange, here is the complete example, can you please try this: package main
import (
"github.com/ansrivas/fiberprometheus/v2" // v2.6.1
"github.com/gofiber/fiber/v2" // v2.48.0
)
func main() {
app := fiber.New()
public := app.Group("/public")
admin := app.Group("/admin")
prometheus := fiberprometheus.NewWithLabels(map[string]string{
"component": "fiberprometheus",
}, "somesystem", "http")
prometheus.RegisterAt(app, "/metrics")
app.Use(prometheus.Middleware)
public.Get("/somepath", func(c *fiber.Ctx) error {
return c.SendString("Hello World from somepath")
})
admin.Get("/adminpath", func(c *fiber.Ctx) error {
return c.SendString("Hello World from adminpath")
})
app.Listen(":3000")
}
|
I think I got what's going on I think I was able to identify when the path is not correct (at least some cases)
public := app.Group("/public")
prometheus := fiberprometheus.NewWithLabels(labels, strings.ReplaceAll(Component, "-", "_"), "http")
prometheus.RegisterAt(app, "/metrics")
app.Use(prometheus.Middleware)
// if this returns, the path in the metric is /public instead of /lesson/:id/:page
public.Use(auth.Middleware(datasource))
public.Get("/lesson/:id/:page", func(c *fiber.Ctx) error {})
|
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. |
Heya! I've noticed this as well with one of my apps. The comment above was what I noticed as well, the / paths were all cache hits for me. I've added a test here, that makes it super clear. https://github.com/Fesaa/fiberprometheus/commit/e748341c6afd9aada719e7aa50c318fc51a0aaa9 I'm looking around a bit, but am not seeing a solution without changes within fiber at the moment. Am planning to look a bit longer as it annoys me a lot as it makes my grafana graphs wrong 😄 |
@FedeBev @Fesaa I submitted a PR that includes the new cache metrics from @Fesaa and also fixes the issues @FedeBev was running into with the path's. I also fixed a concurrency issues happening with the default global registry. This middleware is going to be migrated to https://github.com/gofiber/contrib in the next week or so. Maintenance will be done by the GoFiber team (I'm one of the maintainers). |
@FedeBev @Fesaa Migration has started and is being tracked here gofiber/contrib#1032 I have a |
Hi there,
thanks for this work!
When using
a.Group
the path is not correct.With the following app
The following metrics are created when calling
GET /public/somepath
I'd expect to see
/public/somepath
in thepath
label.Thanks!
The text was updated successfully, but these errors were encountered: