-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unintuitive behaviour of RegisterAt with custom registry (#181)
This commit fixes some counterintuitive behaviour when creating the middleware with a custom registry. Previously, using a custom registry with additional metrics requires avoiding the RegisterAt function, which used only the prometheus.DefaultGatherer. Given a *prometheus.Registry, instead of the more intuitive: ``` fp := fiberprometheus.NewWithRegistry(reg, "my-application", "http", "", nil) fp.RegisterAt(app, "/metrics") ``` One would have to do this: ``` app.Get("/metrics", adaptor.HTTPHandler(promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))) ``` The change here detects when the `prometheus.Registerer` is also a `prometheus.Gatherer`, and then uses the `prometheus.Gatherer` when calling `RegisterAt`. This change will _not_ fix work in the case of a custom implementation of `prometheus.Registerer` when the that implementation is not _also_ a `prometheus.Gatherer`, which is an unlikely situation for inexperienced users of prometheus. For the more common case of passing a `*prometheus.Registry`, this change will provide a more intuitive experience.
- Loading branch information
calloway-jacob
authored
Oct 21, 2023
1 parent
3f27009
commit 7015afd
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters