-
Notifications
You must be signed in to change notification settings - Fork 170
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
chore(metrics): refactor metrics v2 so it uses classes #1920
chore(metrics): refactor metrics v2 so it uses classes #1920
Conversation
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.
Thanks Mauro!
Yes these changes work for me. We would need a Falco PR as well for the changes related to libs::metrics::libsinsp_metrics::new_metric
. Would you mind opening that one as well?
@FedeDP WDYT? It also needs to be coordinated with your open PR.
@@ -46,39 +48,6 @@ struct sinsp_stats_v2 | |||
uint32_t m_n_containers; | |||
}; | |||
|
|||
enum sinsp_stats_v2_resource_utilization | |||
{ | |||
SINSP_RESOURCE_UTILIZATION_CPU_PERC = 0, ///< Current CPU usage, `ps` util like calculation for the calling process (/proc/self), unit: percentage of one CPU. |
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.
Could we keep the comments somewhere? Perhaps when we emplace_back the metrics? Just so the next developer understands better where they come from, as some metrics definitely benefit from having 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.
Agree with Melissa!
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.
Sounds good, I'll find a new home for them!
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 added the comments back, but instead of doing so where we emplace the variables, I added them next to the variables that store the values. I feel this closer resembles the original positions for the comments and has the benefit that it adds doxygen documentation for those fields.
I also used member groups to prevent duplicating some comments, this one is a bit nastier and I'm not fully convinced it's the right way to go about it, let me know what you think.
Also CC @sgaist, thanks! |
/milestone 0.18.0 |
I'll get that up and running as soon as I can, it might take a minute since I've never actually compiled Falco as a whole 😅 |
Also, since I might take sometime to put together the falco counter part to this PR, feel free to merge yours and I'll rebase this one, think perf testing is more important too. |
Let's see what get merged first ahah |
I'm still working on the main repo counterpart for this PR, think I have a working change but have to test it still, should have it up for review soonish. |
Perf diff from master - unit tests
Perf diff from master - scap file
|
We merged Fede's PR first. @Molter73 when you get a chance could you rebase and once the Falco PR is up we can merge it quickly. |
This is an alternative to the original implementation. Instead of using capturing lambdas that get called back after some additional work is done, we use classes and gather data during instantiation of the object. This approach should be a lot more straight forward and it also doesn't create unneeded objects when there's no need to do so. Signed-off-by: Mauro Ezequiel Moltrasio <[email protected]>
Signed-off-by: Mauro Ezequiel Moltrasio <[email protected]>
ac75f33
to
8d7c712
Compare
Perf diff from master - unit tests
Perf diff from master - scap file
Heap diff from master - unit tests
Heap diff from master - scap file
|
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.
Like it!
/approve
LGTM label has been added. Git tree hash: b530ef1f44e4c7353f654f45179681abd85410fe
|
/hold Still need to open the main repo counterpart. |
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.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, incertum, Molter73 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This commit will be dropped once falcosecurity/libs#1920 is merged and replaced with a commit to the master branch. Signed-off-by: Mauro Ezequiel Moltrasio <[email protected]>
This commit will be dropped once falcosecurity/libs#1920 is merged and replaced with a commit to the master branch. Signed-off-by: Mauro Ezequiel Moltrasio <[email protected]>
I've opened falcosecurity/falco#3265 as the counter part to this PR, if everything looks good over there, we can go ahead and merge this. |
/unhold |
What type of PR is this?
This is an alternative to the original implementation. Instead of using capturing lambdas that get called back after some additional work is done, we use classes and gather data during instantiation of the object. This approach should be a lot more straight forward and it also doesn't create unneeded objects when there's no need to do so. Another benefit of this approach is that metrics are bundled together in a very specific way, rather than depending on the ordering of definitions in an enum, which is a C idiom.
/kind cleanup
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
At the time of creation, this refactoring is merely a proposal, any other changes are welcomed and the possibility of completely scrapping the PR in favor of a better alternative is also up there
Does this PR introduce a user-facing change?: