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

cgroups2/Stats: split out reading cpu, memory, memory events #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thaJeztah
Copy link

As outlined in the PR, usage_usec, user_usec, and system_use may always exist, but in situations where the files parsed do not exist, we shouldn't have to try to assign values (which would always be 0).

Split out parsing of these to separate functions, so make this more transparent.

return &metrics, nil
}

func readMemoryEvents(cgroupPath string) (*stats.MemoryEvents, error) {
Copy link
Author

Choose a reason for hiding this comment

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

Alternatively, this could be a method (instead of passing the path as argument);

Suggested change
func readMemoryEvents(cgroupPath string) (*stats.MemoryEvents, error) {
func (c *Manager) readMemoryEvents() (*stats.MemoryEvents, error) {

My consideration was that having it as a plain function could be easier to add unit tests for, but of course we could probably construct a Manager{path: "some custom path"}, so probably either way would work

As outlined in the PR, usage_usec, user_usec, and system_use may
always exist, but in situations where the files parsed do not
exist, we shouldn't have to try to assign values (which would always
be 0).

Split out parsing of these to separate functions, so make this more
transparent.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant