--- id: starlette-exporter version: "0.24.0" license: Apache License 2.0 license_treatment: permissive maintenance: active --- # starlette-exporter — Prometheus metrics exporter for Starlette applications. License: permissive · Maintenance: active · Downloads: 1.9M/mo ## What it is and what it does starlette_exporter is a middleware that automatically instruments Starlette applications to collect HTTP metrics compatible with Prometheus. It tracks three core metrics: total request count (starlette_requests_total), request duration distribution (starlette_request_duration_seconds), and concurrent requests in progress (starlette_requests_in_progress). Each metric is labeled by HTTP method, request path, and response status code, allowing fine-grained monitoring and alerting. The middleware integrates as a standard Starlette middleware and exposes metrics via a /metrics endpoint that Prometheus can scrape. It supports customization through options like custom labels (static or request-derived), histogram bucket configuration, path grouping for cardinality control, and filtering or grouping of unhandled paths. It also provides helper functions to extract label values from request or response headers with cardinality constraints. Use it for: - Monitor request latency distribution and identify performance regressions in Starlette services. - Track concurrent request volume to detect capacity issues and inform auto-scaling decisions. - Add custom labels from headers to correlate metrics with deployment environment or tenant information. - Exclude health-check or probe endpoints from metrics collection to reduce noise and cardinality. - Integrate trace IDs as exemplars in Prometheus histograms to link metrics to distributed traces. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Collects and exports Prometheus metrics for Starlette and FastAPI applications, tracking request counts, response times, and concurrent request volumes with configurable labels and histogram buckets. Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a standard need for Prometheus monitoring of web applications. The permissive Apache 2.0 license poses no restrictions. Install it if you run Starlette and need Prometheus metrics without writing custom instrumentation. ## Install pip install starlette-exporter uv add starlette-exporter poetry add starlette-exporter ## Installing starlette-exporter Before you install: Low friction: pure Python wheel with only two runtime dependencies (prometheus_client and starlette). Actively maintained with recent releases; last commit 2026-07-29. License in practice: Apache License 2.0 (permissive): you can use, modify, and distribute this package freely in commercial and open-source projects, provided you include a copy of the license and state significant changes. Quickstart: pip install starlette_exporter from starlette.applications import Starlette from starlette_exporter import PrometheusMiddleware, handle_metrics app = Starlette() app.add_middleware(PrometheusMiddleware) app.add_route("/metrics", handle_metrics) Verify before relying: - Whether the package works with all current versions of prometheus_client and starlette, or if specific version ranges are required. - Performance overhead of metric collection in high-throughput scenarios. - Compatibility with frameworks beyond Starlette (e.g., FastAPI) given only starlette is listed as a runtime dependency. ## Package facts - License: Apache License 2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags prometheus metrics starlette, request monitoring middleware, http metrics exporter, prometheus histogram counter gauge, application performance metrics, starlette middleware monitoring, web framework instrumentation, prometheus, observability, middleware [View on SkillFed](https://skillfed.io/packages/starlette-exporter) · [View on PyPI](https://pypi.org/project/starlette-exporter/)