Add WrapCollectorWith and WrapCollectorWithPrefix#1766
Merged
kakkoyun merged 1 commit intoprometheus:mainfrom Apr 10, 2025
Merged
Add WrapCollectorWith and WrapCollectorWithPrefix#1766kakkoyun merged 1 commit intoprometheus:mainfrom
WrapCollectorWith and WrapCollectorWithPrefix#1766kakkoyun merged 1 commit intoprometheus:mainfrom
Conversation
I found myself in a situation where I had to instantiate multiple instances of a third party library that registered some metrics and never un-registered them. In my app's lifecycle I needed to un-register them and then register them again, but I couldn't achieve that by wrapping the Registerer. I decided to register that library's metrics in a separate Registry and register that Registry, but in order to handle multiple instances of the library, I also needed to wrap it with labels, and while such functionality existed already as part of the Registerer wrapping, it wasn't exposed. This PR just exposes Collector wrapping as a public function. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
ArthurSens
approved these changes
Mar 18, 2025
Member
ArthurSens
left a comment
There was a problem hiding this comment.
Thanks for the test and example, makes the review process pretty smooth and showcase why we'd ever want something like this :)
LGTM, but if possible I'd like to see an approval from someone else who has been more active than I've been during the last couple of months 😅. Maybe @bwplotka or @kakkoyun ?
Contributor
Author
|
Hi, any chance we could get this merged? |
Member
|
I'm merging it. We will still have time to have subsequent PRs until the next release if we want to change anything. |
ying-jeanne
pushed a commit
to ying-jeanne/client_golang
that referenced
this pull request
Apr 16, 2025
I found myself in a situation where I had to instantiate multiple instances of a third party library that registered some metrics and never un-registered them. In my app's lifecycle I needed to un-register them and then register them again, but I couldn't achieve that by wrapping the Registerer. I decided to register that library's metrics in a separate Registry and register that Registry, but in order to handle multiple instances of the library, I also needed to wrap it with labels, and while such functionality existed already as part of the Registerer wrapping, it wasn't exposed. This PR just exposes Collector wrapping as a public function. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
juliusmh
pushed a commit
to juliusmh/client_golang
that referenced
this pull request
Jun 30, 2025
I found myself in a situation where I had to instantiate multiple instances of a third party library that registered some metrics and never un-registered them. In my app's lifecycle I needed to un-register them and then register them again, but I couldn't achieve that by wrapping the Registerer. I decided to register that library's metrics in a separate Registry and register that Registry, but in order to handle multiple instances of the library, I also needed to wrap it with labels, and while such functionality existed already as part of the Registerer wrapping, it wasn't exposed. This PR just exposes Collector wrapping as a public function. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
1 task
1 task
1 task
1 task
1 task
1 task
Merged
1 task
Merged
1 task
1 task
Merged
1 task
1 task
Open
1 task
1 task
1 task
This was referenced Mar 5, 2026
Merged
This was referenced Mar 13, 2026
Open
Open
1 task
1 task
1 task
1 task
This was referenced Mar 27, 2026
Closed
This was referenced Mar 28, 2026
This was referenced Mar 30, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found myself in a situation where I had to instantiate multiple instances of a third party library that registered some metrics and never un-registered them.
In my app's lifecycle I needed to un-register them and then register them again, but I couldn't achieve that by wrapping the Registerer.
I decided to register that library's metrics in a separate Registry and register that Registry, but in order to handle multiple instances of the library, I also needed to wrap it with labels, and while such functionality existed already as part of the Registerer wrapping, it wasn't exposed.
This PR just exposes Collector wrapping as a public function.