-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix bug in filtering, cleanup #31595
Fix bug in filtering, cleanup #31595
Conversation
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
totalCPUDeltaMillis := int64(s1.CPU.Total.Ticks.ValueOr(0) - s0.CPU.Total.Ticks.ValueOr(0)) | ||
|
||
pct := float64(totalCPUDeltaMillis) / float64(timeDeltaMillis) | ||
// In theory this can only happen if the time delta is 0, which is unlikely but possible. | ||
if timeDeltaMillis == 0 { |
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.
You are doing this comparison against a float now, which leaves it open to floating point precisions issues comparing against an exact value.
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.
Ah, good point.
} | ||
// We use this to track processes over time. | ||
procStats.ProcsMap = pidMap | ||
|
||
// filter the process list that will be passed down to users | ||
procStats.includeTopProcesses(plist) | ||
plist = procStats.includeTopProcesses(plist) |
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 this the primary bug?
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.
yup.
t.Logf("Proc: %s", procData[0].StringToPrint()) | ||
} | ||
|
||
func TestFilter(t *testing.T) { |
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.
This was the missing test from the looks of things?
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.
Yah, added that.
❕ Build Aborted
Expand to view the summary
Build stats
Test stats 🧪
Steps errorsExpand to view the steps failures
|
@kvch have we solved the "typecheck failing on stuff that has cgo" issue yet? |
After talking with @kvch, I'm going to merge this without the linters passing, as we don't really care about them here, and the rest of the tests are passing. Tested this myself with a full build of metricbeat. |
* fix bug in filtering, cleanup * continuing to make linter happy * deal with platform-specific code issues (cherry picked from commit 2a6624d) # Conflicts: # libbeat/metric/system/process/process.go # libbeat/metric/system/process/process_darwin.go # libbeat/metric/system/process/process_linux_common.go
* Fix bug in filtering, cleanup (#31595) * fix bug in filtering, cleanup * continuing to make linter happy * deal with platform-specific code issues (cherry picked from commit 2a6624d) # Conflicts: # libbeat/metric/system/process/process.go # libbeat/metric/system/process/process_darwin.go # libbeat/metric/system/process/process_linux_common.go * fix cherry-pick * format again Co-authored-by: Alex K <8418476+fearful-symmetry@users.noreply.github.com> Co-authored-by: Alex Kristiansen <alex.kristiansen@elastic.co>
* fix bug in filtering, cleanup * continuing to make linter happy * deal with platform-specific code issues
What does this PR do?
This PR fixes a bug results in the
top_n
filtering options not being applied insystem/process
, as well as refactors a bunch of components to make the new linter happy.Why is it important?
This is an actual bug.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Pull down and build, make sure the
include_top_n
flags work in metricbeat.