-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Updates to Logging Middleware #1974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Logging middleware now tracks and logs request duration alongside other request information. Duration is measured using time.perf_counter() and displayed in milliseconds, following the same pattern as the existing timing middleware. Co-authored-by: William Easton <strawgate@users.noreply.github.com>
We should probably also remove the timestamp (or make it optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the logging middleware to track request duration, update logger namespacing, and improve error handling. The changes align with issue #1973 and enhance the observability of the FastMCP server.
Key changes include:
- Added request duration tracking using
time.perf_counter()
and reporting in milliseconds - Updated logger names to use the
fastmcp.middleware.*
namespace pattern - Improved error logging to include error type information in structured format
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/fastmcp/server/middleware/logging.py |
Core logging middleware implementation with duration tracking, updated namespacing, and improved error handling |
tests/server/middleware/test_logging.py |
Updated test suite to validate new duration tracking, logger namespacing, and structured logging improvements |
Cleaned up the tests a little bit with a helper function for extracting logs from caplog
Closes #1973