feat: Enhanced error handling, validation, and reset endpoint#26
Open
mygithubappforkaushal[bot] wants to merge 1 commit intomainfrom
Open
Conversation
## Summary This PR adds production-ready improvements to the analyser service and load testing script. ## Changes Made ### 1. **Enhanced Analyser Error Handling & Logging** (`analyser/app.py`) - ✅ Added structured logging with proper log levels (INFO, WARNING, ERROR) - ✅ Improved `/analyse` endpoint with proper error handling and HTTP status codes - Returns `503 Service Unavailable` when analyser is in failed state - Returns `500 Internal Server Error` on processing failures - Added detailed logging for packet processing - ✅ Enhanced Pydantic models with field validation: - Added `Field` descriptors for better API documentation - Validation rules: non-empty strings, positive timestamps, non-empty message lists - ✅ Improved docstrings for all endpoints ### 2. **New Reset Endpoint** (`analyser/app.py`) - ✅ Added `/internal/reset` POST endpoint (addresses TODO in original comments) - Resets packet and message counters to zero - Maintains alive/dead state - Returns previous counts for verification - Useful for testing and benchmarking scenarios ### 3. **Enhanced Load Testing Script** (`locustfile.py`) - ✅ Added comprehensive module and function docstrings - ✅ Renamed `AnalyserUser` → `DistributorUser` (more accurate naming) - ✅ Added `DEBUG` log level to test scenarios - ✅ Improved code readability with extracted variables ## Benefits - **Better observability**: Structured logging helps with debugging and monitoring - **Improved reliability**: Proper error handling and HTTP status codes - **Enhanced testability**: Reset endpoint allows clean benchmark runs - **Better documentation**: Auto-generated OpenAPI docs will be more informative • [View Chat](http://localhost:3000/chat/01KM4CD6H4EBX0H5NPWRXVM2HC) Co-authored-by: Resolve AI <code-agent@resolve.ai>
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 production-ready improvements to the analyser service and load testing script.
Changes Made
1. Enhanced Analyser Error Handling & Logging (
analyser/app.py)/analyseendpoint with proper error handling and HTTP status codes503 Service Unavailablewhen analyser is in failed state500 Internal Server Erroron processing failuresFielddescriptors for better API documentation2. New Reset Endpoint (
analyser/app.py)/internal/resetPOST endpoint (addresses TODO in original comments)3. Enhanced Load Testing Script (
locustfile.py)AnalyserUser→DistributorUser(more accurate naming)DEBUGlog level to test scenariosBenefits
• View Chat
Co-authored-by: Resolve AI code-agent@resolve.ai