Can Python package `py-grpc-prometheus` be used with the Python gRPC AsyncIO version?

119 views
Skip to first unread message

Adrian Gay

unread,
Feb 14, 2022, 10:41:14 AM2/14/22
to grpc.io

We are converting existing Python gRPC services to the Python gRPC AsyncIO version (1.43.1). We currently use the py-grpc-prometheus package to collect/emit server and client metrics. This packages subclasses:

```
class PromServerInterceptor(grpc.ServerInterceptor): 

class PromClientInterceptor(grpc.UnaryUnaryClientInterceptor, grpc.UnaryStreamClientInterceptor, grpc.StreamUnaryClientInterceptor, grpc.StreamStreamClientInterceptor):
```
 and uses a number of other gRPC package attributes, etc.

The question is, are the blocking and asyncio classes 'compatible' when used in this way? If not, any suggestions on alternative ways of collecting server/client request/response metrics?

Thank you:)

Lidi Zheng

unread,
Feb 16, 2022, 2:07:50 PM2/16/22
to grpc.io
The interceptor API for AsyncIO is different than the normal interceptor API. AsyncIO requires the method signatures to pass on "async"-ness from function to function.

If there is an AsyncIO metrics library, it should be possible to integrate with gRPC AsyncIO. However, if there isn't, the metrics library is likely to be using transports (gRPC, HTTP). The IO from transport is blocking, and will be harder to integrate into the AsyncIO world.

Reply all
Reply to author
Forward
0 new messages