-
Notifications
You must be signed in to change notification settings - Fork 22
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
consider devices which have been off for more than 7 days #3697
Conversation
📝 WalkthroughWalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## staging #3697 +/- ##
========================================
Coverage 11.62% 11.62%
========================================
Files 107 107
Lines 14885 14885
Branches 274 274
========================================
Hits 1730 1730
Misses 13155 13155
|
Device registry changes in this PR available for preview here |
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: 0
🧹 Outside diff range and nitpick comments (2)
src/device-registry/models/Event.js (2)
24-24
: Approved: UPTIME_CHECK_THRESHOLD update aligns with PR objective.The change from 48 to 168 hours (7 days) for the
UPTIME_CHECK_THRESHOLD
constant aligns well with the PR objective to consider devices that have been off for more than 7 days. This adjustment will affect the frequency of uptime alerts and overall system behavior.Consider adding a comment explaining the rationale behind this 7-day threshold, which could be helpful for future maintenance.
Inconsistent Uptime Threshold Constants Detected
It appears that both
UPTIME_THRESHOLD
andUPTIME_CHECK_THRESHOLD
are used within the codebase with different values:
UPTIME_THRESHOLD
:
src/device-registry/utils/scripts/downtime-report.js
: 48src/device-registry/bin/jobs/v2-check-network-status-job.js
: 50UPTIME_CHECK_THRESHOLD
:
src/device-registry/models/Event.js
: 168This inconsistency can lead to confusion and potential bugs. It's recommended to:
- Consolidate these constants into a single
UPTIME_THRESHOLD
to maintain consistency across the codebase.- Update all references to ensure they use the unified constant.
- Document the chosen threshold value and its purpose clearly.
🔗 Analysis chain
Line range hint
1004-1048
: Consider the implications of the increased UPTIME_CHECK_THRESHOLD on logging frequency.The
filterNullAndReportOffDevices
function now uses the increasedUPTIME_CHECK_THRESHOLD
of 168 hours (7 days). This change will result in:
- Less frequent logging of "off" devices, as the threshold has been extended from 2 to 7 days.
- Potential reduction in the volume of logs generated.
- Delayed detection of devices that have gone offline, which might be intentional based on the PR objective.
Consider adding a comment in this function to explain the 7-day threshold and its implications on device monitoring.
To ensure this change doesn't adversely affect the system's ability to monitor device status, we should verify the impact on log volume and device status tracking. Here's a script to check the current log patterns:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check the current log patterns for device uptime alerts # Search for log entries related to device uptime rg "Last refreshed time difference exceeds" --type jsLength of output: 97
Script:
#!/bin/bash # Description: Check the current log patterns for device uptime alerts in JavaScript files # Search for log entries related to device uptime in JavaScript files rg "Last refreshed time difference exceeds" --type jsLength of output: 511
Script:
#!/bin/bash # Description: Find definitions of UPTIME_THRESHOLD and UPTIME_CHECK_THRESHOLD across the codebase # Search for definition of UPTIME_THRESHOLD rg "const\s+UPTIME_THRESHOLD\s*=" --type js # Search for definition of UPTIME_CHECK_THRESHOLD rg "const\s+UPTIME_CHECK_THRESHOLD\s*=" --type jsLength of output: 340
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- src/device-registry/models/Event.js (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
src/device-registry/models/Event.js (1)
24-24
: Verify the system-wide impact of the UPTIME_CHECK_THRESHOLD change.While the
UPTIME_CHECK_THRESHOLD
constant is only directly used in thefilterNullAndReportOffDevices
function, the implications of this change from 2 days to 7 days might affect other parts of the system that rely on the uptime check results.To ensure this change doesn't have unintended consequences, please verify:
- Any dashboards or reports that display device uptime statistics.
- Any alerts or notifications systems that might be triggered by device downtime.
- Any data analysis or machine learning models that use device uptime as a feature.
Here's a script to help identify potential areas affected by this change:
#!/bin/bash # Description: Identify potential areas affected by UPTIME_CHECK_THRESHOLD change # Search for files that might be using the results of uptime checks rg -t js -t python "device.*uptime|uptime.*check|device.*status"
Description
During uptime checks, consider devices which have been off for more than 7 days
Summary by CodeRabbit
Bug Fixes
Chores