larzmetrics
Application metrics with Prometheus export. Pure Python, zero dependencies.
Instrument your code and expose the numbers in the Prometheus text format every scraper and dashboard understands — without pulling in the official client (and its protobuf).
from larzmetrics import Registry
reg = Registry()
reqs = reg.counter("http_requests_total", "requests", labelnames=["method"])
reqs.labels(method="GET").inc()
reg.gauge("temperature", "temp").set(21.5)
lat = reg.histogram("request_seconds", "latency")
with lat.time():
handle_request()
print(reg.render()) # Prometheus text exposition format
Why
- Counters, gauges, histograms — monotonic counters, settable gauges, and
histograms with configurable buckets,
_sum/_count, and atime()context manager for latencies. - Labels —
metric.labels(method="GET").inc(), exactly like the Prometheus client. - Scrape-ready —
render()produces the standard text exposition format (# HELP/# TYPE,_bucket{le=...},+Inf), so any Prometheus/Grafana/ OpenMetrics tool reads it. Serve it at/metricsand you're done. - Zero dependencies. No
prometheus_client, no protobuf.
Install
pip install larzmetrics
Usage
reg = Registry()
c = reg.counter("name", "help", labelnames=["a", "b"])
c.labels(a="1", b="2").inc(5)
g = reg.gauge("temp", "help"); g.set(20); g.inc(); g.dec(2)
h = reg.histogram("lat", "help", buckets=[0.1, 0.5, 1, 2, 5])
h.observe(0.3)
with h.time():
work()
reg.render() # str, Prometheus format
Pairs with larzlog for observability
and any WSGI app (serve render() at /metrics).
Tests
python -m unittest discover -s tests -v # 10 tests
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.
License
MIT © larz-scripter
Metadata
Release files for larzmetrics 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| larzmetrics-0.1.0.tar.gz | 5.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzmetrics-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.6 kB
Release files / larzmetrics-0.1.0.tar.gz
| Download URL | larzmetrics-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d52f5c06a75fbd908cdee9bca8e257e9590dfc4a86af4a3f1eabad2d33be108
|
|
BLAKE2b-256 checksum How to use checksums |
2d2ce661288a572bfd33c2ad01de356e8c10fcc402d2b8a1c2ed038d57003fdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzmetrics-0.1.0-py3-none-any.whl
| Download URL | larzmetrics-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9e3539e9790ab4088bede5745301ee95936d479ffb40afd079bb333397405db
|
|
BLAKE2b-256 checksum How to use checksums |
6d7f99acf7ca2b018bff8515fdfcd343fef9875c00ed93168e50c24a4ae5d53e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for larzmetrics 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.