Python gRPC Prometheus Interceptors
Project description
python-grpc-prometheus
ChangeLog
Installation
Installation from PyPI:
pip install python-grpc-prometheus
Usage
Check the available interceptors in the source code. This example uses the PromServerInterceptor
.
Usage example:
import grpc
from concurrent.futures import ThreadPoolExecutor
# Importing this whole package so that I can use prometheus_client.start_http_server()
# instead of just start_http_server(), which is not too descriptive. But it's your call.
import prometheus_client
from python_grpc_prometheus.prometheus_server_interceptor import PromServerInterceptor
# Add the required interceptor(s) where you create your grpc server, e.g.
psi = PromServerInterceptor()
server = grpc.server(ThreadPoolExecutor(max_workers=10), interceptors=(psi,))
# Start the http server where prometheus can fetch the data from. Use whatever listen port you prefer.
prometheus_client.start_http_server(8000)
# ...
Now, when running your application, you can check http://localhost:8000 in a browser.
Note: the grpc_*
metrics will just show commented out (with their descriptions) until your application actually receives gRPC calls.
TODO
- add stream support
- add client metrics
- add test
- add example
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
Close
Hashes for python_grpc_prometheus-0.1.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca08676316c5d388b3010a3dd3a906feb2e9a0af196a7f829916403958020fce |
|
MD5 | 24c49ae7bde40204fa19e17f790776d5 |
|
BLAKE2b-256 | e282d2c8a2edf3788b9254968e3acb7696b32be5d521501c025e8e2ae1e83a49 |