Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

sam57719
Copy link
Contributor

  • Introduced SensorLogMonitorState model to track the state of sensor log monitoring.
  • Added a scheduled monitoring job to alert when sensor logs are missing, with configurable thresholds.
  • Updated SmibhidSensorPluginConfig to include new monitoring options. (See SETTINGS.md)
  • Enhanced utility module with the get_humanized_timedelta function for human-readable time differences.
  • Adjusted the plugin to enable or disable monitoring based on the provided configuration.
  • Set tz_aware=True for AsyncMongoClient to ensure timezone-aware database operations.
  • Improved configuration flexibility and added validation for the two existing plugin configurations. (missed out the static plugin for now)

…xisting plugin configs. New issue raised for DRYing the config validation
…iguration flexibility

- Introduced `SensorLogMonitorState` model for tracking monitoring state.
- Added monitoring job to alert on missing sensor logs based on configurable thresholds.
- Updated `SmibhidSensorPluginConfig` to include monitoring settings.
- Enhanced utility module with `get_humanized_timedelta` for user-friendly time outputs.
- Adjusted plugin to conditionally enable or disable monitoring based on configuration.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Implements sensor log monitoring functionality with configurable alerts and improves configuration validation across the codebase.

  • Added monitoring job to detect when sensor logs are missing beyond configurable thresholds
  • Enhanced configuration system with better error handling and validation
  • Introduced timezone-aware database operations for improved reliability

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/smib/utilities/init.py Adds humanized time delta formatting utility
src/smib/plugins/lifecycle_manager.py Enhanced plugin registration error handling for configuration failures
src/smib/db/manager.py Enables timezone-aware MongoDB operations
src/smib/config/_env_base_settings.py Adds enum parsing and none string handling
src/smib/config/init.py Makes validation error formatter public and updates signature
src/plugins/space/spacestate/config.py Adds configuration validation with proper error handling
src/plugins/space/smibhid/sensor/models.py Adds monitoring state model and latest log query method
src/plugins/space/smibhid/sensor/config.py New configuration class for sensor monitoring settings
src/plugins/space/smibhid/sensor/init.py Implements scheduled sensor log monitoring with Slack alerts
src/plugins/space/smibhid/init.py Updates plugin registration to include scheduler interface
SETTINGS.md Documents new sensor monitoring configuration options
README.md Updates plugin description to mention monitoring feature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sam57719
Copy link
Contributor Author

sam57719 commented Sep 25, 2025

@sjefferson99 Ok, I've updated as per the GH Copilot review - all made sense!
Retested with some data-phaffing and still looks to work as intended, and doesn't crash with a null last_alert_sent value.

@sjefferson99
Copy link
Member

@sam57719 Code looks good bar the comment above. I will pull onto smib-dev and confirm I can get it to build and trigger warnings.

Copy link
Member

@sjefferson99 sjefferson99 left a comment

Choose a reason for hiding this comment

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

Refactor of code block in comment.

…dability and reuse

- Extracted monitoring logic into helper functions: `_log_monitoring_settings`, `_fetch_latest_log`, `_compute_monitor_flags`, `_send_alert`, and `_update_monitor_state`.
- Streamlined sensor monitor setup with `setup_monitor_job` and `setup_routes` for clearer structure.
- Improved separation of concerns for better maintainability.
@sam57719
Copy link
Contributor Author

Pushed a refactored version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notification when no sensor logs received within X minutes
2 participants