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

Add Deregister to metrics.MultiGatherer interface #3498

Merged
merged 2 commits into from
Oct 26, 2024

Conversation

StephenButtolph
Copy link
Contributor

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 the metrics.MultiGatherer interface.

How this was tested

  • Added unit tests.

Need to be documented in RELEASES.md?

No.

@StephenButtolph StephenButtolph self-assigned this Oct 25, 2024
@StephenButtolph StephenButtolph added the monitoring This primarily focuses on logs, metrics, and/or tracing label Oct 25, 2024
@StephenButtolph StephenButtolph added this to the v1.11.13 milestone Oct 25, 2024

package utils

// DeleteIndex moves the last element in the slice to index [i] and shrinks the
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@StephenButtolph StephenButtolph added this pull request to the merge queue Oct 26, 2024
Merged via the queue into master with commit acb3d7d Oct 26, 2024
23 checks passed
@StephenButtolph StephenButtolph deleted the add-deregister-to-multi-gatherer branch October 26, 2024 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
monitoring This primarily focuses on logs, metrics, and/or tracing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants