Skip to content

Fix #68: Add safety_events_last_hour metric to /health endpoint - #923

Open
10-49 wants to merge 10 commits into
ascherj:mainfrom
10-49:fix/68-health-endpoint-safety-count
Open

Fix #68: Add safety_events_last_hour metric to /health endpoint#923
10-49 wants to merge 10 commits into
ascherj:mainfrom
10-49:fix/68-health-endpoint-safety-count

Conversation

@10-49

@10-49 10-49 commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Adds a safety_events_last_hour count to the /health endpoint so operators can monitor recent safety system activity directly without having to check external dashboards. It uses Redis sorted sets to track event totals over trailing 60 minutes and includes fallback handling so monitoring issues don't break the main health check.

Issue

Closes #68

Changes

-Updated safety/monitoring.py to record individual event timestamps in Redis sorted sets and added get_events_in_window() to count events over a rolling timeframe

  • Updated api/routes/health.py to call get_safety_events_last_hour() and include the metric in the JSON response
  • Added try/except error handling around the safety check in api/routes/health.py so it outputs to null if Redis/monitoring is down without throwing a 503
  • Added comprehensive unit test suites in tests/unit/test_monitoring.py and tests/unit/test_health.py

Testing

  • [✅] Unit tests pass (make test-unit)
  • [✅] Linter passes (make lint)
  • [✅] Type checker passes (make typecheck)
  • [✅] New/updated tests cover the changes

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.

Add a safety event count to the health check endpoint

1 participant