Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

metrics: introduce custom registry #7051

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

Draft
mohammed90 wants to merge 4 commits into master
base: master
Choose a base branch
Loading
from custom-metrics-registry
Draft

Conversation

Copy link
Member

@mohammed90 mohammed90 commented Jun 5, 2025

Module developers who add custom metrics are used to wrapping the registration with a sync.Once to avoid duplicate registration panic and control the registration. However, the flow of caddy reload doesn't play nice with this idiom.

Since the introduction of registry-per-context, we've told some users to ignore the duplicate registration error if received. However, checking for this particular error is annoying. I wonder if owning the sync.Once and tracking the registration is better. I don't know if this is the best flow.

dzmitry-lahoda reacted with thumbs up emoji
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
@mohammed90 mohammed90 added discussion 💬 The right solution needs to be found under review 🧐 Review is pending before merging labels Jun 5, 2025
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

I don't fully understand this (the metrics stuff in general) but it looks good to me -- no obvious red flags 😅

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Copy link
Member Author

The key I'm using to track uniqueness isn't optimal because a single Caddy module may register multiple collectors. Extracting the unique identifiers using the Describe method is hard because theDesc type only has String method, and it's hard to extract both fqName and the const labels (unique combo) from the string. So I changed it to just swallow the duplicate registration error but bubble the rest. I doubt it's best-practice but cannot think of a better way.

Copy link
Member

mholt commented Jun 9, 2025

That does sound like a tricky one. That's probably fine? We can see if it causes any issues but maybe it's not too likely, or is at least preventable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@francislavoie francislavoie francislavoie left review comments

@mholt mholt mholt approved these changes

@dunglas dunglas Awaiting requested review from dunglas

@hairyhenderson hairyhenderson Awaiting requested review from hairyhenderson

Assignees

No one assigned

Labels

discussion 💬 The right solution needs to be found under review 🧐 Review is pending before merging

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /