Python FastAPI performance monitoring agent - Route-level tracing, WebSocket integration, request/response profiling, middleware performance analysis, and real-time API metrics collection.
npm install @stacksleuth/fastapi-agentStackSleuth FastAPI Agent




Python FastAPI performance monitoring agent - Route-level tracing, WebSocket integration, request/response profiling, middleware performance analysis, and real-time API metrics collection.
- 🚀 FastAPI Route Tracing: Automatic endpoint performance monitoring
- 🔄 WebSocket Support: Real-time monitoring with WebSocket integration
- 📊 Request/Response Profiling: Detailed HTTP transaction analysis
- 🔧 Middleware Integration: FastAPI middleware performance tracking
- 🐍 Async Support: Full async/await performance monitoring
- 📈 API Metrics: RESTful API performance analytics
- 🛡️ Dependency Tracking: FastAPI dependency injection monitoring
- ⚡ Production Ready: High-performance Python integration
``bashnpm
npm install @stacksleuth/fastapi-agent
`bash
yarn add @stacksleuth/fastapi-agent
``bash
pnpm add @stacksleuth/fastapi-agent
`🏁 Quick Start
`python
from fastapi import FastAPI
from stacksleuth.fastapi import StackSleuthMiddleware, StackSleuthapp = FastAPI()
Add StackSleuth middleware
app.add_middleware(StackSleuthMiddleware,
enabled=True,
sample_rate=0.1)Initialize StackSleuth
stacksleuth = StackSleuth()@app.get("/users")
async def get_users():
with stacksleuth.span("fetch-users"):
# Your business logic
users = await User.find_all()
return {"users": users}
@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket):
await websocket.accept()
# WebSocket monitoring automatically included
`
🛠️ Troubleshooting
$3
Agent Not Starting
`typescript
// Enable debug mode
const agent = new FastapiAgent({
enabled: true,
debug: true
});
`High Memory Usage
`typescript
// Optimize memory usage
const agent = new FastapiAgent({
bufferSize: 500,
flushInterval: 5000,
sampleRate: 0.01
});
`Missing Metrics
- Check that the agent is enabled
- Verify your API key and project ID
- Ensure sampling rate allows data through
- Check network connectivity to StackSleuth API
$3
`bash
DEBUG=stacksleuth:* node your-app.js
``- Official Documentation
- API Reference
- Examples Repository
We welcome contributions! Please see our Contributing Guide for details.
MIT License - see the LICENSE file for details.
---
Website •
Documentation •
NPM Registry •
GitHub
Made with ⚡ by StackSleuth