python-prometheus-client
Port variant py311
Summary Client for Prometheus monitoring system (3.11)
Package version 0.15.0
Homepage https://github.com/prometheus/client_python
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants py310
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 01 JAN 2023, 17:21:46 UTC
Port created 01 JAN 2023, 17:21:46 UTC
Subpackage Descriptions
single # Prometheus Python Client The official Python client for [Prometheus]. ## Three Step Demo **One**: Install the client: ``` pip install prometheus-client ``` **Two**: Paste the following into a Python interpreter: ```python from prometheus_client import start_http_server, Summary import random import time # Create a metric to track time spent and requests made. REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request') # Decorate function with metric. @REQUEST_TIME.time() def process_request(t): """A dummy function that takes some time.""" time.sleep(t) if __name__ == '__main__': # Start up the server to expose the metrics. start_http_server(8000) # Generate some requests. while True: process_request(random.random()) ``` **Three**: Visit [http://localhost:8000/] to view the metrics. From one easy to use decorator you get: * `request_processing_seconds_count`: Number of times this function was called. * `request_processing_seconds_sum`: Total amount of time spent in this function. Prometheus's `rate` function allows calculation of both requests per second, and latency over time from this data. In addition if you're on Linux the `process` metrics expose CPU, memory and other information about the process for free! ## Installation ``` pip install prometheus-client ``` This package can be found on [PyPI]. ## Instrumenting Four types of metric are offered: Counter, Gauge, Summary and Histogram. See the documentation on [metric types] and [instrumentation best practices] on how to use them. ### Counter Counters go up, and reset when the process restarts. ```python from prometheus_client import Counter c = Counter('my_failures', 'Description of counter') c.inc() # Increment by 1 c.inc(1.6) # Increment by given value ``` If there is a suffix of `_total` on the metric name, it will be removed. When exposing the time series for counter, a `_total` suffix will be added. This is for compatibility between OpenMetrics and the Prometheus text format, as OpenMetrics requires the `_total` suffix. There are utilities to count exceptions raised: ```python @c.count_exceptions() def f(): pass with c.count_exceptions(): pass # Count only one type of exception with c.count_exceptions(ValueError): pass ```
Configuration Switches (platform-specific settings discarded)
PY310 OFF Build using Python 3.10 PY311 ON Build using Python 3.11
Package Dependencies by Type
Build (only) python-pip:single:py311
autoselect-python:single:standard
Build and Runtime python311:single:standard
Download groups
main mirror://PYPIWHL/2e/5e/4225463cdac1098aac718b1d8adf8f9dc3d6aaea55f4f85a2f7d572b4f7c
Distribution File Information
db7c05cbd13a0f79975592d112320f2605a325969b270a94b71dcabc47b931d2 60097 prometheus_client-0.15.0-py3-none-any.whl
Ports that require python-prometheus-client:py311
python-django-prometheus:py311 Django app monitor with Prometheus.io (3.11)