Skip to main content

Python gRPC Prometheus Interceptors

Project description

python-grpc-prometheus

Build Status

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

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

python_grpc_prometheus-0.2.0.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file python_grpc_prometheus-0.2.0.tar.gz.

File metadata

  • Download URL: python_grpc_prometheus-0.2.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8

File hashes

Hashes for python_grpc_prometheus-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9dcc3bec8d3b5ced4381b8b13c224d3c499b6957e09b1edd4dbea6832e80f7d3
MD5 ced7bedf887f71ad41e9ea9d8555d765
BLAKE2b-256 71b8e799163d7bb76d6ad2b8362a218f0e2e0044ebc415870261978d23fc4847

See more details on using hashes here.

Supported by

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