lchenn / py-grpc-prometheus

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

Fix server interceptor & tests #40

Closed awong-evoiq closed 6 months ago

awong-evoiq commented 6 months ago

Follow-up to #37 & #38.

Recompiles the integration test protos, which were causing test failures due to being built with an old protoc version.

Updates the integration test server so that it imitates 3 different types of errors:

Fixes the server interceptor so that it does not count errors when skip_exceptions is enabled. (I'm not sure why this is desired, but it is expected by the tests).

When an unexpected Exception is raised, the ServerContext.code is still set to StatusCode.OK. Adds a check to treat an Exception with OK status as an UNKNOWN. This is the same behavior as https://github.com/grpc/grpc/blob/v1.62.0/src/python/grpcio/grpc/_server.py#L397-L402.

Note: all github workflow checks should pass before merging.