-
Notifications
You must be signed in to change notification settings - Fork 675
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
Add Deregister
to metrics.MultiGatherer
interface
#3498
Conversation
|
||
package utils | ||
|
||
// DeleteIndex moves the last element in the slice to index [i] and shrinks the |
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 understand this is O(1) and not O(n) like the regular slices.Delete
but it is less code and less complexity to just use the aforementioned builtin slices.Delete
over adding a new method.
Deregister
isn't called yet in the code, and if called - it will be probably be called seldomly, so I'm not sure if it's worth adding it from a code maintenance perspective.
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.
This definitely isn't performance critical... But I also feel like I've re-implemented this same code like 5 times... So I feel like it is a reasonable helper to add
} | ||
for _, test := range deregisterTests { | ||
t.Run(test.name, func(t *testing.T) { | ||
require := require.New(t) |
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.
(No action required) Maybe use a name other than require
to avoid shadowing the package?
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.
We do this shadowing pretty much everywhere... I feel like the shadowing here is almost beneficial, as there is no reason to ever use any of the functions in the package after this point.
Why this should be merged
Metrics are registered throughout avalanchego, deregistering all of them individually would require extensive additional code flows during the shutdown process. However, there are only a handful of metrics namespaces. This PR allows easily deregistering an entire namespace of metrics.
How this works
Adds
Deregister
to themetrics.MultiGatherer
interface.How this was tested
Need to be documented in RELEASES.md?
No.