mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
change grpc decorator
This commit is contained in:
parent
48f172facb
commit
bdbb70f63f
@ -5,18 +5,24 @@ from milvus.grpc_gen import status_pb2
|
||||
class GrpcSpanDecorator(SpanDecorator):
|
||||
def __call__(self, span, rpc_info):
|
||||
status = None
|
||||
if not rpc_info.response:
|
||||
return
|
||||
if isinstance(rpc_info.response, status_pb2.Status):
|
||||
status = rpc_info.response
|
||||
else:
|
||||
status = rpc_info.response.status
|
||||
try:
|
||||
status = rpc_info.response.status
|
||||
except Exception as e:
|
||||
status = status_pb2.Status(error_code=status_pb2.UNEXPECTED_ERROR,
|
||||
reason='Should not happen')
|
||||
|
||||
if status.error_code == 0:
|
||||
return
|
||||
span.set_tag('error', True)
|
||||
span.set_tag('error_code', status.error_code)
|
||||
error_log = {'event': 'error',
|
||||
'request': rpc_info.request,
|
||||
'response': rpc_info.response
|
||||
}
|
||||
span.set_tag('error', True)
|
||||
span.log_kv(error_log)
|
||||
|
||||
def mark_grpc_method(func):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user