prometheus-client (Python)
Official Python client for Prometheus metrics. Provides Counter, Gauge, Histogram, and Summary metric types with a built-in HTTP /metrics endpoint for Prometheus scraping. Integrates with WSGI (Flask, Django) and ASGI (FastAPI) applications. Standard library for Python service instrumentation in Prometheus-based monitoring stacks.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
/metrics endpoint should be protected — add auth middleware or restrict to internal network. Avoid exposing sensitive data in metric labels. Default metrics include Python runtime info which is acceptable.
⚡ Reliability
Best When
Your infrastructure runs Prometheus/Grafana and you need to instrument Python services with standard metrics (requests, errors, latency, custom business metrics).
Avoid When
You don't run Prometheus — use OpenTelemetry with a different metrics backend or a vendor APM SDK.
Use Cases
- • Expose /metrics HTTP endpoint for Prometheus to scrape application metrics (request count, latency, error rate)
- • Track custom business metrics (orders processed, AI completions, queue depth) as Prometheus counters and gauges
- • Measure request latency distribution with Histogram metrics for SLO/SLA tracking
- • Push metrics to Prometheus Pushgateway for short-lived batch jobs that aren't scraped directly
- • Integrate with Grafana dashboards via Prometheus data source for real-time service visualization
Not For
- • Distributed tracing — use OpenTelemetry for traces; prometheus-client is metrics-only
- • Long-term metrics storage — Prometheus handles retention; for extended history use Thanos or Cortex
- • Log-based metrics — use log aggregation pipelines (ELK, Loki) for log-derived metrics
Interface
Authentication
Library with no auth requirement. /metrics endpoint authentication is application responsibility (add basic auth or IP allowlist in your reverse proxy).
Pricing
Free and open source, part of the official Prometheus project.
Agent Metadata
Known Gotchas
- ⚠ Metrics with labels have unbounded cardinality risk — using user IDs or request paths as label values causes memory explosion; label values must have low cardinality
- ⚠ The default CollectorRegistry is global — tests that register metrics will conflict across test runs; use CollectorRegistry(auto_describe=True) per test
- ⚠ WSGI integration (make_wsgi_app()) and ASGI (make_asgi_app()) require separate setup for async frameworks — the standard start_http_server() blocks in async contexts
- ⚠ Histogram buckets default to [.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10] seconds — customize buckets to match your actual latency distribution for useful percentiles
- ⚠ multiprocess mode (for Gunicorn/uWSGI workers) requires setting PROMETHEUS_MULTIPROC_DIR env var and using MultiProcessCollector — single-process default doesn't work with multiple workers
- ⚠ Counter and Histogram metrics cannot be decremented — use Gauge for values that go up and down (queue depth, active connections)
Alternatives
Full Evaluation Report
Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for prometheus-client (Python).
AI-powered analysis · PDF + markdown · Delivered within 30 minutes
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-06.