|
|
@ -8,6 +8,8 @@ import (
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const messageEvent = "message"
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
// MessageSent is the type of sent messages.
|
|
|
|
// MessageSent is the type of sent messages.
|
|
|
|
MessageSent = messageType(RPCMessageTypeSent)
|
|
|
|
MessageSent = messageType(RPCMessageTypeSent)
|
|
|
@ -22,13 +24,13 @@ type messageType attribute.KeyValue
|
|
|
|
func (m messageType) Event(ctx context.Context, id int, message interface{}) {
|
|
|
|
func (m messageType) Event(ctx context.Context, id int, message interface{}) {
|
|
|
|
span := trace.SpanFromContext(ctx)
|
|
|
|
span := trace.SpanFromContext(ctx)
|
|
|
|
if p, ok := message.(proto.Message); ok {
|
|
|
|
if p, ok := message.(proto.Message); ok {
|
|
|
|
span.AddEvent("message", trace.WithAttributes(
|
|
|
|
span.AddEvent(messageEvent, trace.WithAttributes(
|
|
|
|
attribute.KeyValue(m),
|
|
|
|
attribute.KeyValue(m),
|
|
|
|
RPCMessageIDKey.Int(id),
|
|
|
|
RPCMessageIDKey.Int(id),
|
|
|
|
RPCMessageUncompressedSizeKey.Int(proto.Size(p)),
|
|
|
|
RPCMessageUncompressedSizeKey.Int(proto.Size(p)),
|
|
|
|
))
|
|
|
|
))
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
span.AddEvent("message", trace.WithAttributes(
|
|
|
|
span.AddEvent(messageEvent, trace.WithAttributes(
|
|
|
|
attribute.KeyValue(m),
|
|
|
|
attribute.KeyValue(m),
|
|
|
|
RPCMessageIDKey.Int(id),
|
|
|
|
RPCMessageIDKey.Int(id),
|
|
|
|
))
|
|
|
|
))
|