prometheus-client

The official Python instrumentation library for exposing Prometheus metrics

Library
PyPI
v0.26.0
4,359stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
82/100Excellent
Development Activity76
Maintenance68
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture85
Code Quality84
Innovation70
Learning Curve80

prometheus-client is the official Python client for the Prometheus monitoring system, providing Counter, Gauge, Histogram, Summary, and Info metric types along with a registry that Prometheus scrapes over HTTP in its native exposition format (and OpenMetrics). It ships built-in WSGI and ASGI HTTP servers for exposing a /metrics endpoint, plus integrations for Twisted, aiohttp, and Django.

Beyond straightforward metric instrumentation, it handles the harder operational cases: multiprocess mode for aggregating metrics across pre-forked worker processes (gunicorn, uWSGI), a process collector exposing memory/CPU/fd counts, a platform collector, and a Graphite bridge for pushing metrics to systems that don’t scrape Prometheus natively. It is the de facto standard for instrumenting any Python service intended to be observed by Prometheus.

What You Get

  • Counter, Gauge, Histogram, Summary, and Info metric types with label support
  • Built-in WSGI and ASGI servers (start_http_server, make_asgi_app) for exposing a /metrics endpoint
  • Multiprocess mode for correctly aggregating metrics across pre-forked workers (gunicorn, uWSGI)
  • Framework integrations for Twisted, aiohttp, and Django, plus a process collector for CPU/memory/fd stats
  • OpenMetrics exposition format support alongside the classic Prometheus text format, and a Graphite bridge for push-based systems

Common Use Cases

  • Instrumenting a Python web service (Flask, Django, FastAPI) with request counters, latency histograms, and in-flight gauges for Prometheus to scrape
  • Exposing correct aggregate metrics from a multiprocess WSGI deployment (gunicorn workers) using the library’s multiprocess mode
  • Building custom collectors that pull metrics from an external system (a queue depth, a cache hit ratio) and expose them in Prometheus format
  • Bridging existing Prometheus metrics into a Graphite-based monitoring stack via the built-in push bridge

Under The Hood

Architecture The library centers on a CollectorRegistry that holds registered Collector objects; the four metric types (Counter, Gauge, Histogram, Summary in metrics.py) are themselves collectors that know how to serialize their internal state into Sample objects (samples.py), which exposition.py then renders into the Prometheus text or OpenMetrics wire format for scraping — multiprocess.py and values.py implement an alternate value-storage backend (memory-mapped files via mmap_dict.py) so metrics recorded in separate forked processes can be correctly summed at scrape time, a nontrivial problem this library solves that naive instrumentation code cannot.

Tech Stack Pure Python (3.9+, tested through 3.14 and PyPy) with zero required runtime dependencies for core functionality, using setuptools for packaging; optional integrations (prometheus_client/django, /aiohttp, /twisted, /bridge) are submodules activated only when those frameworks are present, keeping the base install lightweight while covering the major Python web/async ecosystems.

Code Quality The tests/ directory mirrors the source layout closely (test_core, test_multiprocess, test_exposition, test_parser, per-framework test files, and a dedicated tests/openmetrics/ and tests/proc/ for parser and process-collector fixtures), giving broad coverage of both the common path and the trickier multiprocess/OpenMetrics edge cases; the project ships py.typed for type-checker support and has been under continuous maintenance by the Prometheus organization for a decade.

API Design The core API is famously low-friction — Counter('name', 'help').inc() — and this simplicity, replicated across every Prometheus client library regardless of language, is a deliberate design constraint of the Prometheus project so metrics code looks the same whether you’re in Go, Java, or Python; the tradeoff surfaces in multiprocess mode, where correct usage requires understanding an extra environment variable (PROMETHEUS_MULTIPROC_DIR) and registry wiring that isn’t obvious from the basic API alone.

Used by 13 apps in this directory

Python
66%
Apache 2.0

Agent Control

AI Agents

295

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
79
Repo Health
71
Technical
70
Dependency
Built with
Python66%
TypeScript33%
Updated yesterday
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
Python
64%
BSD 3

Flagsmith

Developer Tools · Devops · Ab Testing Experimentation

6,518

Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.

View details
91
Repo Health
82
Technical
65
Dependency
Built with
Python64%
TypeScript31%
Updated today
Go
84%
MIT

Hatchet

AI Development · Developer Tools · Automation

7,749

A Postgres-backed orchestration engine for background tasks, AI agents, and durable workflows that replaces Redis queues and multi-datastore durable execution platforms with a single self-hostable service.

View details
88
Repo Health
83
Technical
69
Dependency
Built with
Go84%
PLpgSQL11%
Updated today
Python
63%
Other

Keep

Devops · Automation · Monitoring

12,224

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
91
Repo Health
79
Technical
67
Dependency
Built with
Python63%
TypeScript36%
Updated today
Python
68%
MIT

Langflow

AI Agents · AI Development

153,450

Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.

View details
90
Repo Health
85
Technical
66
Dependency
Built with
Python68%
TypeScript22%
Updated today
Python
84%
MIT

LiteLLM

AI Development · Developer Tools

56,720

Open source AI gateway and Python SDK that gives you one OpenAI-compatible interface to call 100+ LLM providers, with built-in routing, cost tracking, guardrails, and virtual keys.

View details
92
Repo Health
81
Technical
71
Dependency
Built with
Python84%
TypeScript14%
Updated today
TypeScript
94%
Other

OpenHands

AI Code Assistants · AI Development

84,452

The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.

View details
91
Repo Health
82
Technical
71
Dependency
Built with
TypeScript94%
Updated today
Python
69%
Apache 2.0

otari

AI Development · Developer Tools

393

A self-hosted, OpenAI-compatible LLM gateway that puts one endpoint in front of 40+ providers, with virtual API keys, per-user budgets enforced before spend, and full usage tracking.

View details
77
Repo Health
88
Technical
78
Dependency
Built with
Python69%
TypeScript30%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search