Skip to content

Commit de325c0

Browse files
Corvin LasoggaCoLa5
Corvin Lasogga
authored andcommitted
added setting of code and details in case of cancel
1 parent 28a9c59 commit de325c0

File tree

1 file changed

+11
-0
lines changed
  • instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc

1 file changed

+11
-0
lines changed

instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ def time_remaining(self, *args, **kwargs):
8282
return self._servicer_context.time_remaining(*args, **kwargs)
8383

8484
def cancel(self, *args, **kwargs):
85+
self._code = grpc.StatusCode.CANCELLED
86+
self._details = self._code.value[1]
87+
self._active_span.set_attribute(
88+
SpanAttributes.RPC_GRPC_STATUS_CODE, self._code.value[0]
89+
)
90+
self._active_span.set_status(
91+
Status(
92+
status_code=StatusCode.ERROR,
93+
description=f"{self._code}: {self._details}",
94+
)
95+
)
8596
return self._servicer_context.cancel(*args, **kwargs)
8697

8798
def add_callback(self, *args, **kwargs):

0 commit comments

Comments
 (0)