-
Notifications
You must be signed in to change notification settings - Fork 703
Add zswap metrics: bytes_used and compression_efficiency #1337
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,12 +24,14 @@ import ( | |
| ) | ||
|
|
||
| type memoryCollector struct { | ||
| mBytesUsed *metrics.Int64Metric | ||
| mPercentUsed *metrics.Float64Metric | ||
| mAnonymousUsed *metrics.Int64Metric | ||
| mPageCacheUsed *metrics.Int64Metric | ||
| mUnevictableUsed *metrics.Int64Metric | ||
| mDirtyUsed *metrics.Int64Metric | ||
| mBytesUsed *metrics.Int64Metric | ||
| mPercentUsed *metrics.Float64Metric | ||
| mAnonymousUsed *metrics.Int64Metric | ||
| mPageCacheUsed *metrics.Int64Metric | ||
| mUnevictableUsed *metrics.Int64Metric | ||
| mDirtyUsed *metrics.Int64Metric | ||
| mZswapBytesUsed *metrics.Int64Metric | ||
| mZswapCompressionEfficiency *metrics.Float64Metric | ||
|
|
||
| config *ssmtypes.MemoryStatsConfig | ||
| } | ||
|
|
@@ -105,5 +107,30 @@ func NewMemoryCollectorOrDie(memoryConfig *ssmtypes.MemoryStatsConfig) *memoryCo | |
| klog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryDirtyUsedID, err) | ||
| } | ||
|
|
||
| if _, ok := memoryConfig.MetricsConfigs[string(metrics.MemoryZswapBytesUsedID)]; ok { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add some unit test?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and can you squash the commits after the update?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added unit tests for zswap to the commit and squashed it all into one commit, thanks |
||
| mc.mZswapBytesUsed, err = metrics.NewInt64Metric( | ||
| metrics.MemoryZswapBytesUsedID, | ||
| memoryConfig.MetricsConfigs[string(metrics.MemoryZswapBytesUsedID)].DisplayName, | ||
| "Zswap usage in bytes", | ||
| "Byte", | ||
| metrics.LastValue, | ||
| []string{}) | ||
| if err != nil { | ||
| klog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryZswapBytesUsedID, err) | ||
| } | ||
| } | ||
| if _, ok := memoryConfig.MetricsConfigs[string(metrics.MemoryZswapCompressionEfficiencyID)]; ok { | ||
| mc.mZswapCompressionEfficiency, err = metrics.NewFloat64Metric( | ||
| metrics.MemoryZswapCompressionEfficiencyID, | ||
| memoryConfig.MetricsConfigs[string(metrics.MemoryZswapCompressionEfficiencyID)].DisplayName, | ||
| "Zswap compression efficiency ratio (uncompressed/compressed)", | ||
| "1", | ||
| metrics.LastValue, | ||
| []string{}) | ||
| if err != nil { | ||
| klog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryZswapCompressionEfficiencyID, err) | ||
| } | ||
| } | ||
|
|
||
| return &mc | ||
| } | ||
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.
Is this metric registered and/or launched? I cannot find any documentation and some issues came up when testing locally.
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.
Hi, thanks for the catch! I updated the documentation, the reason for the error is because the metric descriptors have not yet been registered in the backend, once that happens, the errors should be resolved.