[Feat] Implement metrics enhancements and testing scripts for issue #699 #830
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.
Issue #699 - Metrics Enhancements
Overview
This document outlines the changes made to address a subset of the requirements in issue #699, which involved enhancing the metrics functionality in MCP Gateway, and provides instructions for testing these enhancements.
Changes Implemented
1. Enhanced Metrics Calculation Functions
Updated the following functions in
mcpgateway/utils/metrics_common.py
:calculate_success_rate()
: Improved to handle edge cases such as:format_response_time()
: Enhanced to format response times with:2. Admin API Enhancements
Modified
mcpgateway/admin.py
to:3. Services Improvements
Updated metrics retrieval in service modules to support:
How to Test
Follow these steps to verify the metrics enhancements:
Prerequisites
pip install -e .
Testing Core Metrics Functions
Run the unit tests for the metrics functions:
This will verify:
Testing with Manual Data
Start the MCP Gateway server with admin features enabled:
Create test data using the provided script:
This creates test tools with different metrics patterns:
Test the admin UI:
Test CSV export:
Verification Criteria
The issue is considered resolved when:
Additional Notes
metrics_common.py
utility fileTest Files Location
tests/test_metrics_functions.py
tests/setup_test_data.py
Troubleshooting
If the server fails to start with database errors: