Semantic Conventions for gRPC

Status: Experimental

The Semantic Conventions for gRPC extend and override the RPC spans and RPC metrics Semantic Conventions that describe common RPC operations attributes in addition to the Semantic Conventions described on this page.

gRPC Attributes

rpc.system MUST be set to "grpc".

Below is a table of attributes that SHOULD be included on client and server gRPC measurements.

AttributeTypeDescriptionExamplesRequirement Level
rpc.grpc.request.metadata.<key>string[]gRPC request metadata, <key> being the normalized gRPC Metadata key (lowercase), the value being the metadata values. [1]rpc.grpc.request.metadata.my-custom-metadata-attribute=["1.2.3.4", "1.2.3.5"]Opt-In
rpc.grpc.response.metadata.<key>string[]gRPC response metadata, <key> being the normalized gRPC Metadata key (lowercase), the value being the metadata values. [2]rpc.grpc.response.metadata.my-custom-metadata-attribute=["attribute_value"]Opt-In
rpc.grpc.status_codeintThe numeric status code of the gRPC request.0Required

[1]: Instrumentations SHOULD require an explicit configuration of which metadata values are to be captured. Including all request metadata values can be a security risk - explicit configuration helps avoid leaking sensitive information.

[2]: Instrumentations SHOULD require an explicit configuration of which metadata values are to be captured. Including all response metadata values can be a security risk - explicit configuration helps avoid leaking sensitive information.

rpc.grpc.status_code MUST be one of the following:

ValueDescription
0OK
1CANCELLED
2UNKNOWN
3INVALID_ARGUMENT
4DEADLINE_EXCEEDED
5NOT_FOUND
6ALREADY_EXISTS
7PERMISSION_DENIED
8RESOURCE_EXHAUSTED
9FAILED_PRECONDITION
10ABORTED
11OUT_OF_RANGE
12UNIMPLEMENTED
13INTERNAL
14UNAVAILABLE
15DATA_LOSS
16UNAUTHENTICATED

gRPC Status

The table below describes when the Span Status MUST be set to Error or remain unset depending on the gRPC status code and Span Kind.

gRPC Status CodeSpanKind.SERVER Span StatusSpanKind.CLIENT Span Status
OKunsetunset
CANCELLEDunsetError
UNKNOWNErrorError
INVALID_ARGUMENTunsetError
DEADLINE_EXCEEDEDErrorError
NOT_FOUNDunsetError
ALREADY_EXISTSunsetError
PERMISSION_DENIEDunsetError
RESOURCE_EXHAUSTEDunsetError
FAILED_PRECONDITIONunsetError
ABORTEDunsetError
OUT_OF_RANGEunsetError
UNIMPLEMENTEDErrorError
INTERNALErrorError
UNAVAILABLEErrorError
DATA_LOSSErrorError
UNAUTHENTICATEDunsetError