Skip to content
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

new(userspace/libsinsp): support plugins in sinsp-example. #2179

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Dec 3, 2024

What type of PR is this?

/kind feature

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:

Expands sinsp-example to support plugins.
This will be useful to test plugins; moreover in the future when container metadata support will become a plugin(falcosecurity/falco#3403), this will be needed to run tests in CI (like for example e2e tests).

To pass init config/open params, i chose to use a single string following this pattern:
filepath.so|{initconfig}|{openParams}, eg:

./libsinsp/examples/sinsp-example -p "/home/federico/Scaricati/dummy-0.11.4-linux-x86_64/libdummy.so|{\"jitter\": 10}" -f dummy.divisible[4]=1

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@FedeDP
Copy link
Contributor Author

FedeDP commented Dec 3, 2024

/milestone 0.20.0

@poiana poiana added this to the 0.20.0 milestone Dec 3, 2024
@poiana poiana added the size/L label Dec 3, 2024
@@ -55,13 +55,16 @@ static bool ppm_sc_modifies_state = false;
static bool ppm_sc_repair_state = false;
static bool ppm_sc_state_remove_io_sc = false;
static bool enable_glogger = false;
static string engine_string = KMOD_ENGINE; /* Default for backward compatibility. */
static string engine_string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is initialized below when empty.
This way, we can check if another engine was already set and give an error.

@@ -467,6 +536,8 @@ void formatted_dump(sinsp&, sinsp_evt* ev) {
} else if(ev->get_category() == EC_NET || ev->get_category() == EC_IO_READ ||
ev->get_category() == EC_IO_WRITE) {
net_formatter->tostring(ev, output);
} else if(ev->get_info()->category & EC_PLUGIN) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use ev->get_category() because that only works for syscall-based events.

Copy link

github-actions bot commented Dec 3, 2024

Perf diff from master - unit tests

    10.55%     -1.29%  [.] sinsp_parser::reset
     5.25%     +1.06%  [.] sinsp_evt::get_type
     5.34%     -0.86%  [.] next
     5.64%     +0.84%  [.] sinsp::next
     4.31%     -0.82%  [.] gzfile_read
     0.98%     +0.78%  [.] std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, libsinsp::state::dynamic_struct::field_info>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, libsinsp::state::dynamic_struct::field_info> >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::find
     3.81%     -0.69%  [.] sinsp_parser::process_event
     1.39%     +0.68%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release
     0.30%     +0.59%  [.] std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Identity, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::find
     4.58%     -0.59%  [.] sinsp_evt::load_params

Heap diff from master - unit tests

peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

peak heap memory consumption: -2.96K
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Benchmarks diff from master

Comparing gbench_data.json to /root/actions-runner/_work/libs/libs/build/gbench_data.json
Benchmark                                                         Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------
BM_sinsp_split_mean                                            +0.0480         +0.0480           144           151           144           151
BM_sinsp_split_median                                          +0.0519         +0.0519           143           151           143           151
BM_sinsp_split_stddev                                          -0.4091         -0.4091             2             1             2             1
BM_sinsp_split_cv                                              -0.4361         -0.4361             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  -0.0013         -0.0013            57            57            57            57
BM_sinsp_concatenate_paths_relative_path_median                -0.0016         -0.0015            57            57            57            57
BM_sinsp_concatenate_paths_relative_path_stddev                -0.1762         -0.1778             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_cv                    -0.1751         -0.1768             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0007         +0.0007            24            24            24            24
BM_sinsp_concatenate_paths_empty_path_median                   +0.0010         +0.0010            24            24            24            24
BM_sinsp_concatenate_paths_empty_path_stddev                   +0.0720         +0.0717             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_cv                       +0.0713         +0.0709             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.0050         +0.0050            56            56            56            56
BM_sinsp_concatenate_paths_absolute_path_median                +0.0006         +0.0006            56            56            56            56
BM_sinsp_concatenate_paths_absolute_path_stddev                +1.0216         +1.0208             0             1             0             1
BM_sinsp_concatenate_paths_absolute_path_cv                    +1.0116         +1.0107             0             0             0             0
BM_sinsp_split_container_image_mean                            +0.0236         +0.0236           387           396           387           396
BM_sinsp_split_container_image_median                          +0.0262         +0.0262           386           396           386           396
BM_sinsp_split_container_image_stddev                          -0.5557         -0.5562             4             2             4             2
BM_sinsp_split_container_image_cv                              -0.5659         -0.5665             0             0             0             0

Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 52 lines in your changes missing coverage. Please review.

Project coverage is 75.07%. Comparing base (12c8b09) to head (741a53d).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
userspace/libsinsp/examples/test.cpp 0.00% 52 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2179      +/-   ##
==========================================
- Coverage   75.16%   75.07%   -0.10%     
==========================================
  Files         257      257              
  Lines       33736    33779      +43     
  Branches     5755     5788      +33     
==========================================
  Hits        25359    25359              
- Misses       8377     8420      +43     
Flag Coverage Δ
libsinsp 75.07% <0.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@FedeDP FedeDP force-pushed the new/sinsp_example_plugins branch from 2da4baa to 3c19c0c Compare December 3, 2024 09:17
@FedeDP
Copy link
Contributor Author

FedeDP commented Dec 3, 2024

need to fix e2e tests.

Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@poiana
Copy link
Contributor

poiana commented Dec 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit 65ee768 into master Dec 4, 2024
46 of 49 checks passed
@poiana poiana deleted the new/sinsp_example_plugins branch December 4, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants