github.com/lingyao2333/mo-zero@v1.4.1/core/trace/attributes.go (about)

     1  package trace
     2  
     3  import (
     4  	"go.opentelemetry.io/otel/attribute"
     5  	semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
     6  	gcodes "google.golang.org/grpc/codes"
     7  )
     8  
     9  const (
    10  	// GRPCStatusCodeKey is convention for numeric status code of a gRPC request.
    11  	GRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code")
    12  	// RPCNameKey is the name of message transmitted or received.
    13  	RPCNameKey = attribute.Key("name")
    14  	// RPCMessageTypeKey is the type of message transmitted or received.
    15  	RPCMessageTypeKey = attribute.Key("message.type")
    16  	// RPCMessageIDKey is the identifier of message transmitted or received.
    17  	RPCMessageIDKey = attribute.Key("message.id")
    18  	// RPCMessageCompressedSizeKey is the compressed size of the message transmitted or received in bytes.
    19  	RPCMessageCompressedSizeKey = attribute.Key("message.compressed_size")
    20  	// RPCMessageUncompressedSizeKey is the uncompressed size of the message
    21  	// transmitted or received in bytes.
    22  	RPCMessageUncompressedSizeKey = attribute.Key("message.uncompressed_size")
    23  )
    24  
    25  // Semantic conventions for common RPC attributes.
    26  var (
    27  	// RPCSystemGRPC is the semantic convention for gRPC as the remoting system.
    28  	RPCSystemGRPC = semconv.RPCSystemKey.String("grpc")
    29  	// RPCNameMessage is the semantic convention for a message named message.
    30  	RPCNameMessage = RPCNameKey.String("message")
    31  	// RPCMessageTypeSent is the semantic conventions for sent RPC message types.
    32  	RPCMessageTypeSent = RPCMessageTypeKey.String("SENT")
    33  	// RPCMessageTypeReceived is the semantic conventions for the received RPC message types.
    34  	RPCMessageTypeReceived = RPCMessageTypeKey.String("RECEIVED")
    35  )
    36  
    37  // StatusCodeAttr returns an attribute.KeyValue that represents the give c.
    38  func StatusCodeAttr(c gcodes.Code) attribute.KeyValue {
    39  	return GRPCStatusCodeKey.Int64(int64(c))
    40  }