-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Provide helper to "describe by collect". #239
Comments
I think we can&should do the above by default, however it should be disabled by default on custom registries and there should be a way to bypass it on a per-collector basis (e.g. by implementing a no-op Desc). |
How would an implementation look like that does "describe by collect" by default? |
For Go, you'd remove the current Desc from the interface and add a new interface with the Desc. Then based on which interfaces are implemented, you either can auto-collect or use the user-provided Desc. |
I see. Intuitively, I don't like the implicitness of it. Interface upgrades are a double-edged sword. In this case, it would save two lines of code for those that want to use the feature. I also think it's too easy to run into one of the cornercases to make it an implicit default. (Any metric vector won't work without initialization of at least one metric in it, as an example.) |
I suggest to go with a helper function for v0.9 to not change the interfaces right now. |
I imagine the cases where it won't be okay will be quite rare, so the wins in terms of filtering and ease of use will make up for it. |
Note: The suggested change of the interface to make DescribeByCollect implicit if no Describe method exists could still be considered for v0.10. (I'm kind of sceptical right now because it would not be "safe by default", i.e. somebody who naively implements a Collector without Describe would create something that seemingly works but then breaks later in surprising ways. But we can have that discussion when v0.10 is actually being worked on.) |
If the metrics collected by a collector are using the same descriptors over the runtime of a binary, the
Describe
method can be implemented by callingCollect
and then return all theDesc
s of the returned metrics.There are a number of cornercases where this is not possible, so we cannot just do the above by default. However, it can be explicitly used by implementers of Collectors.
The text was updated successfully, but these errors were encountered: