Fix #68: Add safety_events_last_hour metric to /health endpoint - #923
Open
10-49 wants to merge 10 commits into
Open
Fix #68: Add safety_events_last_hour metric to /health endpoint#92310-49 wants to merge 10 commits into
10-49 wants to merge 10 commits into
Conversation
Verified locally that a GET request to /health returns standard service status but omits the required safety_events_last_hour field. Added reproduction comment in api/routes/health.py. Relates to ascherj#68
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
Adds a
safety_events_last_hourcount to the/healthendpoint 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.pyto record individual event timestamps in Redis sorted sets and addedget_events_in_window()to count events over a rolling timeframeapi/routes/health.pyto callget_safety_events_last_hour()and include the metric in the JSON responsetry/excepterror handling around the safety check inapi/routes/health.pyso it outputs tonullif Redis/monitoring is down without throwing a 503tests/unit/test_monitoring.pyandtests/unit/test_health.pyTesting
make test-unit)make lint)make typecheck)