Skip to content
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

Add WrapCollectorWith and WrapCollectorWithPrefix #1766

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

colega
Copy link
Contributor

@colega colega commented Mar 6, 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.

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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant