-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Conversation
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
There was a problem hiding this 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>
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.
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.
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 ofcaddy 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.