Skip to content

Commit

Permalink
Rework gRPC status based on new rules
Browse files Browse the repository at this point in the history
As of open-telemetry#1214, the status codes changed and no longer line up with gRPC
status codes, so now we'll just set `StatusCode.ERROR` and store the
actual gRPC status code in the trace as `grpc.status_code`.
  • Loading branch information
Michael Stella committed Oct 30, 2020
1 parent ffa3b39 commit 07512ef
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ def set_trailing_metadata(self, *args, **kwargs):
def abort(self, code, details):
self.code = code
self.details = details
self._active_span.set_attribute("rpc.status_code", code.name)
self._active_span.set_status(
Status(status_code=StatusCode(code.value[0]), description=details)
Status(status_code=StatusCode.ERROR, description=details)
)
return self._servicer_context.abort(code, details)

Expand All @@ -125,18 +126,16 @@ def set_code(self, code):
self.code = code
# use details if we already have it, otherwise the status description
details = self.details or code.value[1]
self._active_span.set_attribute("rpc.status_code", code.name)
self._active_span.set_status(
Status(status_code=StatusCode(code.value[0]), description=details)
Status(status_code=StatusCode.ERROR, description=details)
)
return self._servicer_context.set_code(code)

def set_details(self, details):
self.details = details
self._active_span.set_status(
Status(
status_code=StatusCode(self.code.value[0]),
description=details,
)
Status(status_code=StatusCode.ERROR, description=details)
)
return self._servicer_context.set_details(details)

Expand Down

0 comments on commit 07512ef

Please sign in to comment.