From bc0884469a9a61340ff36ee2ebdc05d7faf3076b Mon Sep 17 00:00:00 2001 From: Michael Stella Date: Mon, 7 Dec 2020 17:35:14 -0500 Subject: [PATCH] Format span error description properly --- .../opentelemetry/instrumentation/grpc/_server.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py index f204908fc5..3fe859f574 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py @@ -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) @@ -129,7 +132,10 @@ 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) @@ -137,7 +143,10 @@ 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)