--- id: fastapi-profiler version: "1.5.0" license: MIT license_treatment: permissive maintenance: active --- # fastapi-profiler — A FastAPI Middleware of pyinstrument to check your service performance. License: permissive · Maintenance: active · Downloads: 200.8K/mo ## What it is and what it does fastapi-profiler wraps your FastAPI application with a middleware layer that uses pyinstrument to sample and measure the execution time of each request's call stack. It captures which functions consume the most time and reports results in multiple formats (text, HTML, JSON, prof, speedscope). The middleware supports sampling rate control to reduce overhead in production, threshold-based filtering to profile only slow requests, and structured JSON logging for integration with log aggregation systems. The package includes a built-in web dashboard that displays per-route statistics (p95/p99 latencies, error counts, averages) and exposes APIs to toggle profiling on and off at runtime without restarting. You can exclude certain URL paths from profiling, automatically profile all 5xx errors regardless of sampling settings, and keep a rolling history of profiles per route for later inspection. Use it for: - Identify performance bottlenecks in FastAPI endpoints by examining call trees and function-level timing data. - Monitor production services with low-overhead sampling to detect slow requests without profiling every call. - Generate HTML reports of request profiles for sharing with team members or archiving for later analysis. - Use the dashboard to view live per-route statistics and toggle profiling on/off without redeploying. - Automatically capture profiles of failed requests (5xx errors) to diagnose error-path performance issues. - Export profiles in speedscope format for visualization in external performance analysis tools. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Integrates pyinstrument profiling into FastAPI as middleware to measure per-request performance with configurable sampling, thresholds, and output formats. Yes. The package is actively maintained, has no security vulnerabilities, installs with minimal friction, and solves a concrete problem—profiling FastAPI request performance—with flexible configuration for both development and production use. The permissive MIT license removes any licensing concern. Install it if you need per-request profiling or a runtime-configurable performance dashboard for FastAPI. ## Install pip install fastapi-profiler uv add fastapi-profiler poetry add fastapi-profiler ## Installing fastapi-profiler Before you install: Low friction: pure-Python wheel with only two runtime dependencies (fastapi and pyinstrument). Active maintenance with recent release and no known vulnerabilities. License in practice: MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions. Quickstart: pip install fastapi-profiler from fastapi import FastAPI from fastapi_profiler import PyInstrumentProfilerMiddleware app = FastAPI() app.add_middleware(PyInstrumentProfilerMiddleware) # Requests are now profiled and printed to stdout Verify before relying: - Overhead impact of profiling on production throughput at various sampling rates - Memory consumption when storing per-route profile history with max_profiles_per_route set high - Dashboard performance under high request volume ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: active - Downloads: 200.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags fastapi request profiling, performance monitoring middleware, pyinstrument fastapi integration, request latency profiling, fastapi performance dashboard, call stack sampling fastapi, service performance analysis, profiling, performance-monitoring, middleware [View on SkillFed](https://skillfed.io/packages/fastapi-profiler) · [View on PyPI](https://pypi.org/project/fastapi-profiler/)