-
Notifications
You must be signed in to change notification settings - Fork 7
Capture CPU and memory metrics #188
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
Conversation
WalkthroughAdds CPU and memory reporting to sync payloads: a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10–15 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Comment |
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/common/resources.ts (1)
13-22: Consider edge case: division by zero.If
getCpuMemoryUsage()is called twice within the same millisecond,elapsedTimewould be 0, resulting inInfinityforcpuPercent. While extremely unlikely given the sync intervals (10-60 seconds), consider adding a guard:// Calculate elapsed time in microseconds const elapsedTime = (currentTime - lastCpuTime) * 1000; +// Guard against division by zero +if (elapsedTime === 0) { + lastCpuUsage = currentCpuUsage; + lastCpuTime = currentTime; + return null; +} + // Calculate CPU time used (user + system) in microseconds const cpuTime = currentCpuUsage.user -
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/common/client.ts(2 hunks)src/common/resources.ts(1 hunks)src/common/types.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/common/client.ts (1)
src/common/resources.ts (1)
getCpuMemoryUsage(4-35)
🔇 Additional comments (2)
src/common/types.ts (1)
97-100: LGTM! Clean type definition.The
resourcesfield is properly typed to handle both the metric data and null case for the initial measurement.src/common/client.ts (1)
9-9: LGTM! Clean integration of CPU/memory metrics.The function is correctly imported and integrated into the sync payload. The periodic sync intervals (10-60 seconds) are appropriate for measuring CPU usage deltas.
Also applies to: 229-229
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #188 +/- ##
==========================================
+ Coverage 88.28% 88.37% +0.09%
==========================================
Files 44 45 +1
Lines 3755 3785 +30
Branches 533 536 +3
==========================================
+ Hits 3315 3345 +30
Misses 419 419
Partials 21 21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.