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

discovery(k8s): Only register client-go metrics adapters when needed #13992

Merged
merged 1 commit into from Apr 29, 2024

Conversation

heckler1
Copy link

Previously the metrics adapters for client-go were registered in an init function. This resulted in clobbering default metrics providers when these packages are imported into an application that leverages the default client-go metrics registry.

Instead, let's only register these adapters when requested.

@brancz for review

Previously the metrics adapters for client-go were registered in an init function.
This resulted in clobbering default metrics providers when these packages are imported
into an application that leverages the default client-go metrics registry.

Instead, let's only register these adapters when requested.

Signed-off-by: Stephen Heckler <sheckler@cloudflare.com>
@bboreham
Copy link
Member

@ptodev you added this code; what do you think?

@ptodev
Copy link
Contributor

ptodev commented Apr 29, 2024

Hello, the PR looks ok to me. I think the only reason an init() is used right now is to highlight that only the first calls to RegisterWithK8sGoClient() will take effect. I'll leave it up to the Prometheus maintainers to decide on the best way to highlight that.

I personally think it's ok to just leave the PR as it is, since the settings set by RegisterWithK8sGoClient() are always the same, and even calling RegisterK8sClientMetricsWithPrometheus multiple times with different registries should theoretically work ok.

@roidelapluie roidelapluie merged commit ed4e50e into prometheus:main Apr 29, 2024
24 checks passed
@roidelapluie
Copy link
Member

Thanks

@heckler1
Copy link
Author

Thanks for taking a look y'all!

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.

None yet

4 participants