Please take the OpenCensus user survey

Message events

Message event

A message event describes a message sent or received between spans.

It contains the following fields:

Type

Type enumerates the various states of a message event. It can be either of these:

Type Value Description
SENT 1 Indicates that this message was sent
RECEIVED 2 Indicates that this message was sent
UNKNOWN 0 Unknown event type or default value

ID

The identifier for the message to help correlate between SENT and RECEIVED message events. For example it can be useful when matching sequence/state numbers between protocol handshakes or for a streaming RPC. It is recommended to be unique within a span.

Uncompressed size

The number of uncompressed bytes sent or received.

Compressed size

The number of compressed bytes sent or received. If this value is zero, it is assumed to be the same as Uncompressed size

Source code samples

// On the client
span.AddMessageReceiveEvent(seqNumber, 1024, 512)

// On the server
span.AddMessageSendEvent(seqNumber, 1024, 512)
import io.opencensus.trace.MessageEvent;
import io.opencensus.trace.MessageEvent.Type;

// On the client
MessageEvent clientEvent = MessageEvent.builder(Type.RECEIVED, seqNumber)
                                 .setCompressedMessageSize(512)
                                 .setUncompressedMessageSize(1024)
                                 .build();
clientSpan.addMessageEvent(clientEvent);

// On the server
MessageEvent serverEvent = MessageEvent.builder(Type.SENT, seqNumber)
                                 .setCompressedMessageSize(512)
                                 .setUncompressedMessageSize(1024)
                                 .build();
serverSpan.addMessageEvent(serverEvent);
// On the client
span.AddReceivedMessageEvent(seqNumber, 512, 1024);

// On the server
span.AddSentMessageEvent(seqNumber, 512, 1024);
import datetime

clientEvent = time_event.MessageEvent(seqNumber, type=time_event.Type.RECEIVED,
                uncompressed_size_bytes=1024, compressed_size_bytes=512)
span.add_time_event(time_event.TimeEvent(datetime.datetime.utcnow(), clientEvent))

# On the server$
serverEvent = time_event.MessageEvent(seqNumber, type=time_event.Type.SENT,
                uncompressed_size_bytes=1024, compressed_size_bytes=512)
span.add_time_event(time_event.TimeEvent(datetime.datetime.utcnow(), serverEvent))

Visuals

References

Resource URL
Message event definition proto/v1/message_event
Go API Span.AddMessageReceiveEvent Span.AddMessageSendEvent
Java API MessageEvent JavaDoc
C++ API Span.AddMessageReceivedEvent and Span.AddMessageSentEvent
Python API MessageEvent Span.add_time_event