-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add ability to get individual controller stats #53
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
base: main
Are you sure you want to change the base?
Conversation
f8a0dd5 to
7c07d8a
Compare
|
Hi @kolyshkin |
|
Hi @haircommander |
fs/fs.go
Outdated
| return stats, nil | ||
| } | ||
|
|
||
| func (m *Manager) GetCpuStats() (*cgroups.Stats, error) { |
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.
maybe call these Add*Stats and have them take a stats object, so we can iteratively populate rather than needing to merge later
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.
Makes sense.
I have refactored all to Add*Stats.
|
would love to see some unit tests, and maybe even a POC of it being used in an end user project like CRI-O |
I have added the unit tests
I'm not very familiar with codebase of CRI-O, but I can get a quick POC in |
9a446c9 to
3bc182c
Compare
|
LGTM thank you! |
|
@haircommander metrics output |
|
great thanks! cc @kolyshkin @AkihiroSuda @dims @dgrisonnet |
This adds methods to retrieve statistics for individual cgroup controllers (CPU, memory, pids, IO, hugetlb, rdma, misc) instead of requiring all stats to be fetched at once. This enables tools like cadvisor to collect specific metrics with different housekeeping intervals, reducing computational overhead. Fixes: opencontainers#44 Signed-off-by: Sambhav Jain <jnsmbhv@gmail.com>
|
|
||
| // AddMiscStats adds misc statistics to the provided stats object. | ||
| AddMiscStats(stats *Stats) error | ||
|
|
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.
Maybe just add a single method like GetControllerStats(ControllerName) (*Stats, error)
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.
In my opinion, it's better the current way of having clear API of each controller.
Specifying one function with controller name will result in messy switch case logic.
@haircommander wdyt?
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'm open to one function, but I do think it should be appending to the same structure so a caller doesn't have to merge them. WDYT about AddControllerStats(ControllerName, *Stats) error @AkihiroSuda
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.
Perhaps we can have controller names as binary bits (or string[]) , so we can ask for any one or more controller statistics at once?
Something like
type StatsOptions struct {
// Controllers specifies which controllers to query.
// If nil or empty, all controllers are queried.
Controllers string[]
// Future options can be added here, e.g.
// Recursive bool
// ExcludePSI bool
// IncludeFoobar bool
}
type Manager interface {
...
// Stats returns cgroups statistics. Argument opts can be nil.
func (m Manager) Stats(opts *StatsOptions) (*cgroups.Stats, error)
// GetStats returns cgroups statistics.
//
// Deprecated: replace with [Stats](nil).
GetStats() (*Stats, error)
...
}Now, GetStats implementations can be as simple as return Stats(nil)
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.
good idea, that SGTM @kolyshkin
This PR aims to add methods to retrieve statistics for individual cgroup controllers
(CPU, memory, pids, IO, hugetlb, rdma, misc) instead of requiring all
stats to be fetched at once.
Fixes: #44