From ae0fcc6b4d2d3c094013683e1c3a437cc8fa72a1 Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 11 Nov 2019 21:29:14 +0200 Subject: [PATCH] add traces for send/drop rpc forgotten! --- trace.go | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/trace.go b/trace.go index c04c734..af0fc03 100644 --- a/trace.go +++ b/trace.go @@ -152,15 +152,41 @@ func (t *pubsubTracer) RecvRPC(rpc *RPC) { } func (t *pubsubTracer) SendRPC(rpc *RPC, p peer.ID) { - if t != nil { - // TODO + if t == nil { + return } + + now := time.Now().UnixNano() + evt := &pb.TraceEvent{ + Type: pb.TraceEvent_SEND_RPC.Enum(), + PeerID: []byte(t.pid), + Timestamp: &now, + SendRPC: &pb.TraceEvent_SendRPC{ + SendTo: []byte(rpc.from), + Meta: traceRPCMeta(rpc), + }, + } + + t.tracer.Trace(evt) } func (t *pubsubTracer) DropRPC(rpc *RPC, p peer.ID) { - if t != nil { - // TODO + if t == nil { + return } + + now := time.Now().UnixNano() + evt := &pb.TraceEvent{ + Type: pb.TraceEvent_DROP_RPC.Enum(), + PeerID: []byte(t.pid), + Timestamp: &now, + DropRPC: &pb.TraceEvent_DropRPC{ + SendTo: []byte(rpc.from), + Meta: traceRPCMeta(rpc), + }, + } + + t.tracer.Trace(evt) } func traceRPCMeta(rpc *RPC) *pb.TraceEvent_RPCMeta {