-
Notifications
You must be signed in to change notification settings - Fork 36
Dynamic metrics for cpu and net statistics #34
Dynamic metrics for cpu and net statistics #34
Conversation
When I run the example:
EDIT: I figured out we need this to be merged before. |
eb249b8
to
3ebb9cb
Compare
@kindermoumoute The reason behind failing large test was old plugin version Nevertheless large test will fail with latest snap build. Reason behind it is this bug |
3ebb9cb
to
f7c866b
Compare
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.
Functionality LGTM. As this is also a really good code clean up I made comments to improve the code.
metrics := make([]plugin.MetricType, len(mts)) | ||
loadre := regexp.MustCompile(`^/intel/psutil/load/load[1,5,15]`) | ||
cpure := regexp.MustCompile(`^/intel/psutil/cpu.*/.*`) | ||
loadre := regexp.MustCompile(`^/intel/psutil/load/.*`) |
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.
With the same idea than in cpu.go
, and net.go
, wouldn't it make sense to remove those regex and use condition on namespaces instead?
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.
Regex removed
results := make([]plugin.MetricType, len(nss)) | ||
|
||
for i, ns := range nss { | ||
|
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 doesn't change performances, but with the same idea to make the code clear, it might be more readable to set Data_
and Unit_
in variables before creating the metric:
var data interface{}
unit := "B"
switch ns.Element(len(ns) - 1).Value {
case "total":
data = mem.Total
// ...
case "used_percent":
data = mem.UsedPercent
unit = ""
// ...
default:
return nil, fmt.Errorf("Requested memory statistic %s is not found", ns.String())
}
results[i] = plugin.MetricType{
Namespace_: ns,
Data_: data,
Unit_: unit,
}
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.
LGTM. This PR should fix #26 in the same time.
Introduces dynamic metrics to cpu and net statistics
Summary of changes:
How to verify it:
Testing done:
@intelsdi-x/plugin-maintainers