Prometheus metric support
Project description
py_metric_support
Prometheus metric helper.
Install
pip install -e .
Or with requirements files:
pip install -r requirements.txt
pip install -r requirements-dev.txt
Usage
from py_metric_support import Measure, MetricSupport
MetricSupport.counter("requests_total", ("path", "/health")).inc()
MetricSupport.gauge("workers").set(4)
MetricSupport.gauge_on_scrape("build_info", "version", callback=lambda: Measure(1, "0.1.0"))
MetricSupport.summary("request_latency_seconds", ("path", "/health"), quantiles=[0.5, (0.95, 0.01)]).observe(0.123)
print(MetricSupport.to_prometheus())
print(MetricSupport.to_json_string())
quantiles= accepts either raw ranks like 0.5 or (rank, precision) pairs like (0.95, 0.01).
When quantiles are requested, py_metric_support uses the prometheus-summary backend because the official Python Prometheus client exports _sum and _count only.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_metric_support-0.4.0.tar.gz.
File metadata
- Download URL: py_metric_support-0.4.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
237e825d6f10b998dbc63cf1e3ae346a1b569fa4be59b8821a082c4389bb73f2
|
|
| MD5 |
4a7d4cc3f790f97b57473b959d9f16f1
|
|
| BLAKE2b-256 |
6e3a1d9133597a4292b257de4fe4503c9c46c957ad132342332893b8c7b1d485
|
File details
Details for the file py_metric_support-0.4.0-py3-none-any.whl.
File metadata
- Download URL: py_metric_support-0.4.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40c3d177f71066c7ffcf65d7993c8284a2a2a3df55250eb09dddde2fef2ef1fb
|
|
| MD5 |
37654b23f927a1d4a0657d45a23ae663
|
|
| BLAKE2b-256 |
bba3c9f143cb6147b4425d83b5025b372129f85e6ad520c156dfe6e0414ae55d
|