Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func (p *PubSub) handleNewStream(s network.Stream) {

r := msgio.NewVarintReaderSize(s, p.maxMessageSize)
for {
// ignore the values. We only want to know when the first bytes came in.
_, _ = r.NextMsgLen()
// Start the time once we've received the message length
start := time.Now()
msgbytes, err := r.ReadMsg()
if err != nil {
r.ReleaseMsg(msgbytes)
Expand All @@ -84,6 +88,7 @@ func (p *PubSub) handleNewStream(s network.Stream) {
rpc := new(RPC)
err = rpc.Unmarshal(msgbytes)
r.ReleaseMsg(msgbytes)
rpc.timeToReceive = time.Since(start)
if err != nil {
s.Reset()
log.Warnf("bogus rpc from %s: %s", s.Conn().RemotePeer(), err)
Expand Down
221 changes: 147 additions & 74 deletions pb/trace.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pb/trace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ message TraceEvent {
repeated MessageMeta messages = 1;
repeated SubMeta subscription = 2;
optional ControlMeta control = 3;
optional uint64 millisecondsToReceive = 4;
}

message MessageMeta {
optional bytes messageID = 1;
optional string topic = 2;
optional uint64 messageSize = 3;
}

message SubMeta {
Expand Down
3 changes: 3 additions & 0 deletions pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ type RPC struct {

// unexported on purpose, not sending this over the wire
from peer.ID

// timeToReceive is how long it took to receive the message.
timeToReceive time.Duration
}

// split splits the given RPC If a sub RPC is too large and can't be split
Expand Down
Loading
Loading