lchenn / py-grpc-prometheus

Python gRPC Prometheus
Apache License 2.0
48 stars 25 forks source link

Update prometheus_server_interceptor.py #37

Closed popart closed 6 months ago

popart commented 6 months ago

Updates the interceptor to count context.abort() and context.abort_with_status() calls, which are the recommended method for error-handling.

The python implementation of abort() raises a generic python Exception. The status code is stored in the servicer_context.

See https://github.com/grpc/grpc/blob/master/examples/python/errors/server.py. See https://github.com/grpc/grpc/blob/master/src/python/grpcio/grpc/_server.py#L407.