Skip to main content

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

py_metric_support-0.3.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_metric_support-0.3.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file py_metric_support-0.3.0.tar.gz.

File metadata

  • Download URL: py_metric_support-0.3.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for py_metric_support-0.3.0.tar.gz
Algorithm Hash digest
SHA256 99dd6b9e4b3f8350e881958ec62489788b015e0f9faa1bccfa216d6791c8e8d9
MD5 87a6cc58c60f3aef59dbcd9f273cad25
BLAKE2b-256 4dee7d2ccf601009b7127276ad1ec04706136ae4a6e2bbd9c9b4b7bba2cec066

See more details on using hashes here.

File details

Details for the file py_metric_support-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for py_metric_support-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c0ed150a3a539fed89e779b2b4317c696ee75fca35b8b80f928a4dd75408b65
MD5 1519f715db6a32a3483b2dea4f29daa7
BLAKE2b-256 4c763bb90bb4ae328329e1e8a57348ed11d86585fe63cf30d2d0d4fa6d8f07ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page