平衡器接口(interface) Get
方法有一个 put
函数,作为其返回之一,应该在 grpc 调用之后调用:
// The function returns put which is called once the rpc has completed or failed.
// put can collect and report RPC stats to a remote load balancer.
https://github.com/grpc/grpc-go/blob/master/balancer.go#L74
如何获取 gRPC 调用的状态(成功/失败)和统计信息?
使用拦截器是一种替代方法,但如果可以获取状态/统计信息,我希望使用此方法。
最佳答案
目前,您无法访问 put 中的状态/统计信息。有关于收集统计数据的 WIP。完成后,您可以通过作为 Get 输入的上下文访问它们。 ETA 是今年年底。
关于go - 如何从平衡器获取 gPRC 调用状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40111484/