libs
libs copied to clipboard
new(libsinsp): add len() filter transformer
What type of PR is this?
Uncomment one (or more)
/kind <>lines:
/kind feature
Any specific area of the project related to this PR?
Uncomment one (or more)
/area <>lines:
/area libsinsp
Does this PR require a change in the driver versions?
No
What this PR does / why we need it:
This introduces a new len() transformer which acts like you'd expect:
len(some_list)evaluates to the number of elements in the listlen(some_string)evaluates to the length of the string (excluding null terminator of course)len(some_buffer)evaluates to the number of bytes in the buffer
This is also a handy way to check if lists are empty, since we couldn't do it before, which was apparent after a discussion with @leogr and @jasondellaluce .
Which issue(s) this PR fixes:
Fixes #2127
Special notes for your reviewer:
- The implementation slightly changes the transformer interface which now takes the element flags as well
- Do you see any potential corner cases with plugins?
Does this PR introduce a user-facing change?:
new(libsinsp): add len() filter transformer
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: LucaGuerra
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [LucaGuerra]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Perf diff from master - unit tests
5.26% -1.03% [.] sinsp_parser::process_event
4.49% +0.95% [.] next
3.17% +0.84% [.] gzfile_read
3.94% -0.79% [.] sinsp_evt::load_params
6.15% +0.71% [.] sinsp::next
1.70% -0.62% [.] libsinsp::sinsp_suppress::process_event
1.32% -0.56% [.] sinsp_parser::event_cleanup
5.20% +0.55% [.] sinsp_evt::get_type
3.44% +0.54% [.] sinsp_thread_manager::get_thread_ref
2.63% +0.48% [.] sinsp_thread_manager::find_thread
Heap diff from master - unit tests
peak heap memory consumption: -861B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B
Heap diff from master - scap file
peak heap memory consumption: -32B
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.0285 -0.0285 154 149 153 149
BM_sinsp_split_median -0.0282 -0.0281 153 149 153 149
BM_sinsp_split_stddev +0.9625 +0.9624 1 3 1 3
BM_sinsp_split_cv +1.0201 +1.0199 0 0 0 0
BM_sinsp_concatenate_paths_relative_path_mean -0.0018 -0.0018 57 57 57 57
BM_sinsp_concatenate_paths_relative_path_median -0.0019 -0.0020 57 57 57 57
BM_sinsp_concatenate_paths_relative_path_stddev -0.2067 -0.2036 0 0 0 0
BM_sinsp_concatenate_paths_relative_path_cv -0.2054 -0.2022 0 0 0 0
BM_sinsp_concatenate_paths_empty_path_mean +0.0432 +0.0432 24 25 24 25
BM_sinsp_concatenate_paths_empty_path_median +0.0405 +0.0404 24 25 24 25
BM_sinsp_concatenate_paths_empty_path_stddev -0.2387 -0.2389 0 0 0 0
BM_sinsp_concatenate_paths_empty_path_cv -0.2702 -0.2704 0 0 0 0
BM_sinsp_concatenate_paths_absolute_path_mean -0.0302 -0.0302 56 55 56 55
BM_sinsp_concatenate_paths_absolute_path_median -0.0389 -0.0389 56 54 56 54
BM_sinsp_concatenate_paths_absolute_path_stddev +5.7276 +5.7165 0 1 0 1
BM_sinsp_concatenate_paths_absolute_path_cv +5.9373 +5.9259 0 0 0 0
BM_sinsp_split_container_image_mean -0.0110 -0.0110 398 393 398 393
BM_sinsp_split_container_image_median -0.0125 -0.0124 398 393 398 393
BM_sinsp_split_container_image_stddev +0.3031 +0.3030 2 2 2 2
BM_sinsp_split_container_image_cv +0.3177 +0.3176 0 0 0 0
Codecov Report
Attention: Patch coverage is 87.64940% with 31 lines in your changes missing coverage. Please review.
Project coverage is 74.60%. Comparing base (
701e991) to head (5263f40). Report is 1 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| userspace/libsinsp/test/filter_transformer.ut.cpp | 87.89% | 23 Missing :warning: |
| userspace/libsinsp/sinsp_filter_transformer.cpp | 81.81% | 8 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #2131 +/- ##
==========================================
+ Coverage 74.46% 74.60% +0.13%
==========================================
Files 254 254
Lines 33340 33458 +118
Branches 5724 5720 -4
==========================================
+ Hits 24827 24961 +134
+ Misses 8508 8470 -38
- Partials 5 27 +22
| Flag | Coverage Δ | |
|---|---|---|
| libsinsp | 74.60% <87.64%> (+0.13%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
/milestone 0.19.0
Thanks! Addressed comments
LGTM label has been added.