From 883e14cb507d544b8bf7951682996ddfd50ba836 Mon Sep 17 00:00:00 2001 From: Julio Bastida Date: Wed, 26 Aug 2020 21:56:10 +0200 Subject: [PATCH] Check if response has exception before trying to access result --- .../opencensus/ext/grpc/client_interceptor.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/opencensus-ext-grpc/opencensus/ext/grpc/client_interceptor.py b/contrib/opencensus-ext-grpc/opencensus/ext/grpc/client_interceptor.py index 288bf650b..4b05c5c8a 100644 --- a/contrib/opencensus-ext-grpc/opencensus/ext/grpc/client_interceptor.py +++ b/contrib/opencensus-ext-grpc/opencensus/ext/grpc/client_interceptor.py @@ -127,11 +127,12 @@ def _intercept_call( def _callback(self, current_span): def callback(future_response): - grpc_utils.add_message_event( - proto_message=future_response.result(), - span=current_span, - message_event_type=time_event.Type.RECEIVED, - ) + if not future_response.exception(): + grpc_utils.add_message_event( + proto_message=future_response.result(), + span=current_span, + message_event_type=time_event.Type.RECEIVED, + ) self._trace_future_exception(future_response) self.tracer.end_span()