Add status tracking and monitoring improvements (v0.6.0) - #73
Merged
Conversation
…ck status This commit adds comprehensive tracking of the users configuration file to provide better visibility into user data freshness and system state. Changes: - Added file_mtime field to UsersConfig model that tracks the modification time of users.json on load and reload operations - Created _get_config_path() helper method to retrieve the config file path from environment or use default - Exposed user_config_file_mtime as a new Prometheus metric for monitoring - Updated Slack machine status response to include a header line showing: * Age of users config (human-readable format) * Number of configured users * Number of configured fobs - Updated admin.rst documentation with the new Prometheus metric Testing: - Updated existing UsersConfig tests to verify file_mtime is set correctly - Added new test_reload_updates_file_mtime() to ensure mtime updates on reload - Updated Prometheus metric tests to include and verify new metric - Updated Slack handler tests to verify new status header line format - All 156 tests passing with 99% code coverage The file_mtime tracking enables monitoring when user data was last updated, which is useful for detecting stale data and debugging synchronization issues with external systems like NeonOne CRM. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Added server uptime as the first line in the Slack machine status response
to provide visibility into how long the MAC server has been running.
Changes:
- Updated machine_status() in slack_handler.py to calculate and display
server uptime using naturaldelta() format
- Server uptime is calculated from START_TIME config value
- Displayed as "Server uptime: {human-readable-duration}"
- Positioned as the first line, before users config information
Testing:
- Updated both Slack handler status tests to expect the new uptime line
- Added START_TIME to test fixture config
- All 156 tests passing with 99% code coverage
This provides operators with quick visibility into server stability and
helps identify when the server was last restarted.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive status tracking and monitoring improvements to the MAC server, including users configuration file tracking, Prometheus metrics, and enhanced Slack status responses.
Changes
Users Configuration File Tracking
file_mtimefield toUsersConfigmodel that tracks the modification time of users.json_get_config_path()helper method to retrieve config file path from environment or defaultPrometheus Metrics
user_config_file_mtimeas a new Prometheus metric for monitoringdocs/source/admin.rst) with the new metricSlack Status Enhancements
Version
Testing
test_reload_updates_file_mtime()testBenefits
🤖 Generated with Claude Code