-
Notifications
You must be signed in to change notification settings - Fork 23
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
CPU extractors with unit tests #146
CPU extractors with unit tests #146
Conversation
1. Make cadvisor helper func's public to be used in k8swindows extractor 2. Add CPU extractor and add utilization fields 3. Add unit test for CPU extractor. 4. Add unit test data for kubelet summary API 5. Add helper func to convert Pod and Node summary stats to RawMetric
import ( | ||
ci "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight" | ||
awsmetrics "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/metrics" | ||
cExtractor "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors" |
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 there a better import name than cExtractor?
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.
IIRC our linter will want the import names to be all lower case, i.e. awsmetrics
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.
Changed cExtractor
to cextractor
.
I saw import following similar pattern in cadvisor code where import was alias as cInfo
but for now i changed it to cextractor
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.
got it, I didn't realize it as following an established pattern. If there was no pattern I would say "containerextractor" is more clear and avoids non-obvious abbreviations. If there is an established pattern than cExtractor
seems fine.
Approving this rev, curious what the other agents team review thinks. This can be changed in a later PR
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.
Replaced cextractor
back to cExtractor
|
||
// ConvertNodeToRaw Converts Kubelet Node stats to RawMetric. | ||
func ConvertNodeToRaw(nodeStat *stats.NodeStats) *RawMetric { | ||
var rawMetic *RawMetric |
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 there any risk of null pointers when dereferencing here?
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.
Addressed this issue by adding nil checks
1. Changed cExtractor to cextractors 2. Add nil checks to avoid panic during pointer deferences
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.
Added some nit comments. Everything else looks good
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.
Why did we change this file name?
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.
It was extractorhelpers_test
before, I was not able to import helper funcs from test file in file in k8swindows package. That's why i changed it to extractorhelpers.
MemoryStats *stats.MemoryStats | ||
} | ||
|
||
type MetricExtractor interface { |
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.
Can we implement similar to MetricExtractor interface which has method HasValue using the CPUstats?
type MetricExtractor interface {
HasValue(*cinfo.ContainerInfo) bool
GetValue(info *cinfo.ContainerInfo, mInfo CPUMemInfoProvider, containerType string) []*CAdvisorMetric
Shutdown() 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.
I planned to add this func in future PRs but i have added this func now. Thanks!
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.
The name of the file need to be corrected to extractor_helpers_test.go to match cAdvisor
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.
actually cAdvisor file is extractorhelpers
, I am keeping file names without snake pattern in name to keep consistent with cAdvisor.
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.
Name of the file can be corrected to extractor_helpers.go
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 add s
at last but i am still keeping extractorhelpers
to keep consistent with cAdvisor and other pakcages where name doesn't follow snake pattern.
1. Added missing HasValue func in extractors 2. Replaced cextractor with cExtractor 3. Corrected extractorhelper name with missing characters
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.
Addressed some of comments and provided explanation for other comments
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.
It was extractorhelpers_test
before, I was not able to import helper funcs from test file in file in k8swindows package. That's why i changed it to extractorhelpers.
MemoryStats *stats.MemoryStats | ||
} | ||
|
||
type MetricExtractor interface { |
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 planned to add this func in future PRs but i have added this func now. Thanks!
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.
actually cAdvisor file is extractorhelpers
, I am keeping file names without snake pattern in name to keep consistent with cAdvisor.
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 add s
at last but i am still keeping extractorhelpers
to keep consistent with cAdvisor and other pakcages where name doesn't follow snake pattern.
import ( | ||
ci "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight" | ||
awsmetrics "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/metrics" | ||
cExtractor "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors" |
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.
Replaced cextractor
back to cExtractor
1ad51be
into
amazon-contributing:aws-cwa-ciwindows
* Add CPU extractors from kubelet summary API 1. Make cadvisor helper func's public to be used in k8swindows extractor 2. Add CPU extractor and add utilization fields 3. Add unit test for CPU extractor. 4. Add unit test data for kubelet summary API 5. Add helper func to convert Pod and Node summary stats to RawMetric * Refactor code 1. Changed cExtractor to cextractors 2. Add nil checks to avoid panic during pointer deferences * Refactored code 1. Added missing HasValue func in extractors 2. Replaced cextractor with cExtractor 3. Corrected extractorhelper name with missing characters
* Add CPU extractors from kubelet summary API 1. Make cadvisor helper func's public to be used in k8swindows extractor 2. Add CPU extractor and add utilization fields 3. Add unit test for CPU extractor. 4. Add unit test data for kubelet summary API 5. Add helper func to convert Pod and Node summary stats to RawMetric * Refactor code 1. Changed cExtractor to cextractors 2. Add nil checks to avoid panic during pointer deferences * Refactored code 1. Added missing HasValue func in extractors 2. Replaced cextractor with cExtractor 3. Corrected extractorhelper name with missing characters
* Add CPU extractors from kubelet summary API 1. Make cadvisor helper func's public to be used in k8swindows extractor 2. Add CPU extractor and add utilization fields 3. Add unit test for CPU extractor. 4. Add unit test data for kubelet summary API 5. Add helper func to convert Pod and Node summary stats to RawMetric * Refactor code 1. Changed cExtractor to cextractors 2. Add nil checks to avoid panic during pointer deferences * Refactored code 1. Added missing HasValue func in extractors 2. Replaced cextractor with cExtractor 3. Corrected extractorhelper name with missing characters
* Add CPU extractors from kubelet summary API 1. Make cadvisor helper func's public to be used in k8swindows extractor 2. Add CPU extractor and add utilization fields 3. Add unit test for CPU extractor. 4. Add unit test data for kubelet summary API 5. Add helper func to convert Pod and Node summary stats to RawMetric * Refactor code 1. Changed cExtractor to cextractors 2. Add nil checks to avoid panic during pointer deferences * Refactored code 1. Added missing HasValue func in extractors 2. Replaced cextractor with cExtractor 3. Corrected extractorhelper name with missing characters
* Add CPU extractors from kubelet summary API 1. Make cadvisor helper func's public to be used in k8swindows extractor 2. Add CPU extractor and add utilization fields 3. Add unit test for CPU extractor. 4. Add unit test data for kubelet summary API 5. Add helper func to convert Pod and Node summary stats to RawMetric * Refactor code 1. Changed cExtractor to cextractors 2. Add nil checks to avoid panic during pointer deferences * Refactored code 1. Added missing HasValue func in extractors 2. Replaced cextractor with cExtractor 3. Corrected extractorhelper name with missing characters
… commits (#168) Add support for Container Insights on Windows for EKS * Add kubelet summary API for Windows (#142) * CPU extractors with unit tests (#146) * Add memory extractors for pod and node level (#147) * Define structs for CPU and Memory stats (#149) * Add Container level metrics for CPU and memory resources. (#150) * Add storage metrics for container and node level (#151) * Add network metrics (#152) * Enable awscontainerinsights receiver to run inside Host Process container (#153) * Add HCS shim api as alternative source for metric provider (#154) * Add check for host process container before reading from hcshim (#156) * Fix CPU utilization percentage for Windows nodes (#161) * Add List of Metrics for Windows + Design (#166) * fix fstype (#164)
* Add CPU extractors from kubelet summary API 1. Make cadvisor helper func's public to be used in k8swindows extractor 2. Add CPU extractor and add utilization fields 3. Add unit test for CPU extractor. 4. Add unit test data for kubelet summary API 5. Add helper func to convert Pod and Node summary stats to RawMetric * Refactor code 1. Changed cExtractor to cextractors 2. Add nil checks to avoid panic during pointer deferences * Refactored code 1. Added missing HasValue func in extractors 2. Replaced cextractor with cExtractor 3. Corrected extractorhelper name with missing characters # Conflicts: # receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/cpu_extractor.go # receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/diskio_extractor.go # receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/extractor.go # receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/mem_extractor.go # receiver/awscontainerinsightreceiver/internal/k8swindows/kubelet.go
* Add kubelet summary API for Windows (#142) * CPU extractors with unit tests (#146) * Add memory extractors for pod and node level (#147) * Define structs for CPU and Memory stats (#149) * Add Container level metrics for CPU and memory resources. (#150) * Add storage metrics for container and node level (#151) * Add network metrics (#152) * Enable awscontainerinsights receiver to run inside Host Process container (#153) * Add HCS shim api as alternative source for metric provider (#154) * Add check for host process container before reading from hcshim (#156) * Fix CPU utilization percentage for Windows nodes (#161) * Add List of Metrics for Windows + Design (#166) * fix fstype (#164) * Add windows build tag to fix building cw agent on Windows * Downgrade internal/aws/containerinsight from 0.92 0.89 * Separate unit tests in util.go specific for Windows * Fix util unit tests applicable for Windows * Fix goporto issue * Fix lint issue * Fix regression in unit tests caused due to rebasing mainline * Add unit tests for k8s Windows * Add unit test for kubelet client on Windows * Run DCGM scrapper only for CW agent on Linux * Separate out node Volume unit tests for Windows * Add changelog for Container Insights on Windows
Description:
Add CPU extractors from kubelet summary API
Testing: