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

chore: Update uses of prometheus registration to be less likely to panic #2178

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

Conversation

dehaansa
Copy link
Contributor

PR Description

Inspired by #2177 - I don't see a reason that the possibility of a metric being already registered should cause Alloy to panic.

Which issue(s) this PR fixes

None

@dehaansa dehaansa requested review from a team as code owners November 27, 2024 20:57
Copy link
Contributor

@wildum wildum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ptodev
Copy link
Contributor

ptodev commented Nov 28, 2024

It's worth noting that the AlreadyRegisteredError feature is more of an anti-pattern, and should only be used as a last resort. It's not meant to be used regularly for every registration. If there are duplicate registrations, there is likely to be a bug and avoiding the error could just further mask the bug.

To avoid the panic, it's possible to use Register instead of MustRegister and then the error can be propagated.

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.

3 participants