Closed gaby closed 7 months ago
Seems like this PR broke existing code and http metrics will not be collected for users who used default registry and not used RegisterAt (for instance, one could have a separate metrics server, created elsewhere apart from fiberprometheus.New)
@sashayakovtseva That was a bug, the middleware was sharing a global variable. It was exposed when running test in parallel.
You can pass your current registry to the middleware and they both will use the same using NewWithRegistry()
Another option would be adding a config boolean to allow New
use default registry or not. We are moving this middleware to https://github.com/gofiber/contrib I will implement that change there
You can pass your current registry to the middleware and they both will use the same using
NewWithRegistry()
Yeah, I found that out already when metrics disappeared :)
the middleware was sharing a global variable
I guess that is an issue if one has multiple fiberprometheus.New
calls concurrently, correct?
You can pass your current registry to the middleware and they both will use the same using
NewWithRegistry()
Yeah, I found that out already when metrics disappeared :)
the middleware was sharing a global variable
I guess that is an issue if one has multiple
fiberprometheus.New
calls concurrently, correct?
Yes, if you have multiple prometheus-go clients they all use the same defaultRegistry
. So one solution is to create a Registry a pass it to all your clients.
ctx.Request().RequestURI()
.Fixes #187 #191 Closes #195 #196
@ansrivas I figured fixing these issues here first before migrating the middleware would make more sense. That way anyone using this repo will still get them.