python-grpc-prometheus拦截器
python-grpc-prometheus的Python项目详细描述
python grpc普罗米修斯
更改日志
安装
从PYPI安装:
pip install python-grpc-prometheus
用法
检查源代码中可用的拦截器。本例使用PromServerInterceptor
。
用法示例:
importgrpcfromconcurrent.futuresimportThreadPoolExecutor# 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.importprometheus_clientfrompython_grpc_prometheus.prometheus_server_interceptorimportPromServerInterceptor# 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)# ...
现在,运行应用程序时,可以在浏览器中检查http://localhost:8000。
注意:在应用程序实际接收到grpc调用之前,grpc_*
度量将只显示注释(及其描述)。
待办事项
- 添加流支持