Skip to content

Commit

Permalink
Format span error description properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Stella committed Dec 7, 2020
1 parent be48f30 commit bc08844
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ def abort(self, code, details):
self.details = details
self._active_span.set_attribute("rpc.grpc.status_code", code.value[0])
self._active_span.set_status(
Status(status_code=StatusCode.ERROR, description=details)
Status(
status_code=StatusCode.ERROR,
description="{}:{}".format(code, details),
)
)
return self._servicer_context.abort(code, details)

Expand All @@ -129,15 +132,21 @@ def set_code(self, code):
self._active_span.set_attribute("rpc.grpc.status_code", code.value[0])
if code != grpc.StatusCode.OK:
self._active_span.set_status(
Status(status_code=StatusCode.ERROR, description=details)
Status(
status_code=StatusCode.ERROR,
description="{}:{}".format(code, details),
)
)
return self._servicer_context.set_code(code)

def set_details(self, details):
self.details = details
if self.code != grpc.StatusCode.OK:
self._active_span.set_status(
Status(status_code=StatusCode.ERROR, description=details)
Status(
status_code=StatusCode.ERROR,
description="{}:{}".format(self.code, details),
)
)
return self._servicer_context.set_details(details)

Expand Down

0 comments on commit bc08844

Please sign in to comment.