Skip to content

Commit d2fc6ed

Browse files
Add gRPC status code attributes to error handling in client
1 parent f7e1a7b commit d2fc6ed

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ def callback(response_future):
6060
code = response_future.code()
6161
if code != grpc.StatusCode.OK:
6262
rpc_info.error = code
63+
span.set_attribute(RPC_GRPC_STATUS_CODE, code.value[0])
64+
span.set_status(
65+
Status(
66+
status_code=StatusCode.ERROR,
67+
description=str(code),
68+
)
69+
)
6370
return
6471
response = response_future.result()
6572
rpc_info.response = response

0 commit comments

Comments
 (0)