Skip to content

Conversation

@jantman
Copy link
Owner

@jantman jantman commented Nov 30, 2025

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

  • Added file_mtime field to UsersConfig model that tracks the modification time of users.json
  • Created _get_config_path() helper method to retrieve config file path from environment or default
  • File mtime is updated on both initial load and reload operations

Prometheus Metrics

  • Exposed user_config_file_mtime as a new Prometheus metric for monitoring
  • Updated admin documentation (docs/source/admin.rst) with the new metric

Slack Status Enhancements

  • Added server uptime to Slack machine status response
  • Added users configuration age, user count, and fob count to status response
  • Status response now shows:
    • Server uptime (human-readable format)
    • Users config age, number of users, and number of fobs
    • Machine statuses (existing functionality)

Version

  • Bumped version from 0.5.0 to 0.6.0

Testing

  • Updated existing tests to verify file_mtime tracking
  • Added new test_reload_updates_file_mtime() test
  • Updated Prometheus metric tests to include new metric
  • Updated Slack handler tests to verify new status format
  • All 156 tests passing with 99% code coverage

Benefits

  • Monitoring: File mtime tracking enables monitoring when user data was last updated
  • Debugging: Helps detect stale data and synchronization issues with NeonOne CRM
  • Visibility: Server uptime and users config info provide quick operational insights
  • Observability: New Prometheus metric enables alerting on stale user data

🤖 Generated with Claude Code

jantman and others added 4 commits November 30, 2025 11:47
…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 <[email protected]>
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 <[email protected]>
@github-actions
Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/dm_mac
   __init__.py690100% 
   cli_utils.py150100% 
   neongetter.py1860100% 
   slack_handler.py1560100% 
   utils.py250100% 
src/dm_mac/models
   __init__.py00100% 
   machine.py361199%670
   users.py1010100% 
src/dm_mac/views
   __init__.py00100% 
   api.py220100% 
   machine.py690100% 
   prometheus.py1020100% 
TOTAL1106199% 

Tests Skipped Failures Errors Time
156 0 💤 0 ❌ 0 🔥 12.526s ⏱️

@jantman jantman merged commit 5c95451 into main Nov 30, 2025
16 checks passed
@jantman jantman deleted the status-updates branch November 30, 2025 16:54
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.

2 participants