You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
3 years ago
|
package trace
|
||
3 years ago
|
|
||
|
import (
|
||
|
"go.opentelemetry.io/otel/attribute"
|
||
|
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
|
||
3 years ago
|
gcodes "google.golang.org/grpc/codes"
|
||
3 years ago
|
)
|
||
|
|
||
|
const (
|
||
|
// GRPCStatusCodeKey is convention for numeric status code of a gRPC request.
|
||
|
GRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code")
|
||
3 years ago
|
// RPCNameKey is the name of message transmitted or received.
|
||
3 years ago
|
RPCNameKey = attribute.Key("name")
|
||
3 years ago
|
// RPCMessageTypeKey is the type of message transmitted or received.
|
||
3 years ago
|
RPCMessageTypeKey = attribute.Key("message.type")
|
||
3 years ago
|
// RPCMessageIDKey is the identifier of message transmitted or received.
|
||
3 years ago
|
RPCMessageIDKey = attribute.Key("message.id")
|
||
3 years ago
|
// RPCMessageCompressedSizeKey is the compressed size of the message transmitted or received in bytes.
|
||
3 years ago
|
RPCMessageCompressedSizeKey = attribute.Key("message.compressed_size")
|
||
3 years ago
|
// RPCMessageUncompressedSizeKey is the uncompressed size of the message
|
||
|
// transmitted or received in bytes.
|
||
3 years ago
|
RPCMessageUncompressedSizeKey = attribute.Key("message.uncompressed_size")
|
||
|
)
|
||
|
|
||
|
// Semantic conventions for common RPC attributes.
|
||
|
var (
|
||
3 years ago
|
// RPCSystemGRPC is the semantic convention for gRPC as the remoting system.
|
||
3 years ago
|
RPCSystemGRPC = semconv.RPCSystemKey.String("grpc")
|
||
3 years ago
|
// RPCNameMessage is the semantic convention for a message named message.
|
||
3 years ago
|
RPCNameMessage = RPCNameKey.String("message")
|
||
3 years ago
|
// RPCMessageTypeSent is the semantic conventions for sent RPC message types.
|
||
|
RPCMessageTypeSent = RPCMessageTypeKey.String("SENT")
|
||
|
// RPCMessageTypeReceived is the semantic conventions for the received RPC message types.
|
||
3 years ago
|
RPCMessageTypeReceived = RPCMessageTypeKey.String("RECEIVED")
|
||
|
)
|
||
|
|
||
3 years ago
|
// StatusCodeAttr returns a attribute.KeyValue that represents the give c.
|
||
|
func StatusCodeAttr(c gcodes.Code) attribute.KeyValue {
|
||
3 years ago
|
return GRPCStatusCodeKey.Int64(int64(c))
|
||
|
}
|