Skip to content

Commit

Permalink
expose more events for RawTracer
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMure authored and aschmahmann committed Jul 13, 2021
1 parent 55d412e commit 50b1cfa
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
3 changes: 3 additions & 0 deletions gossip_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ func (gt *gossipTracer) Leave(topic string) {}
func (gt *gossipTracer) Graft(p peer.ID, topic string) {}
func (gt *gossipTracer) Prune(p peer.ID, topic string) {}
func (gt *gossipTracer) DuplicateMessage(msg *Message) {}
func (gt *gossipTracer) RecvRPC(rpc *RPC) {}
func (gt *gossipTracer) SendRPC(rpc *RPC, p peer.ID) {}
func (gt *gossipTracer) DropRPC(rpc *RPC, p peer.ID) {}

func (gt *gossipTracer) ThrottlePeer(p peer.ID) {
gt.Lock()
Expand Down
9 changes: 9 additions & 0 deletions peer_gater.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ func (pg *peerGater) AcceptFrom(p peer.ID) AcceptStatus {
return AcceptControl
}

// -- RawTracer interface methods
var _ RawTracer = (*peerGater)(nil)

// tracer interface
func (pg *peerGater) AddPeer(p peer.ID, proto protocol.ID) {
pg.Lock()
Expand Down Expand Up @@ -440,3 +443,9 @@ func (pg *peerGater) DuplicateMessage(msg *Message) {
}

func (pg *peerGater) ThrottlePeer(p peer.ID) {}

func (pg *peerGater) RecvRPC(rpc *RPC) {}

func (pg *peerGater) SendRPC(rpc *RPC, p peer.ID) {}

func (pg *peerGater) DropRPC(rpc *RPC, p peer.ID) {}
6 changes: 6 additions & 0 deletions score.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,12 @@ func (ps *peerScore) DuplicateMessage(msg *Message) {

func (ps *peerScore) ThrottlePeer(p peer.ID) {}

func (ps *peerScore) RecvRPC(rpc *RPC) {}

func (ps *peerScore) SendRPC(rpc *RPC, p peer.ID) {}

func (ps *peerScore) DropRPC(rpc *RPC, p peer.ID) {}

// message delivery records
func (d *messageDeliveries) getRecord(id string) *deliveryRecord {
rec, ok := d.records[id]
Expand Down
7 changes: 5 additions & 2 deletions tag_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,8 @@ func (t *tagTracer) RejectMessage(msg *Message, reason string) {
}
}

func (t *tagTracer) RemovePeer(peer.ID) {}
func (gt *tagTracer) ThrottlePeer(p peer.ID) {}
func (t *tagTracer) RemovePeer(peer.ID) {}
func (t *tagTracer) ThrottlePeer(p peer.ID) {}
func (t *tagTracer) RecvRPC(rpc *RPC) {}
func (t *tagTracer) SendRPC(rpc *RPC, p peer.ID) {}
func (t *tagTracer) DropRPC(rpc *RPC, p peer.ID) {}
18 changes: 18 additions & 0 deletions trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ type RawTracer interface {
DuplicateMessage(msg *Message)
// ThrottlePeer is invoked when a peer is throttled by the peer gater.
ThrottlePeer(p peer.ID)
// RecvRPC is invoked when an incoming RPC is received.
RecvRPC(rpc *RPC)
// SendRPC is invoked when a RPC is sent.
SendRPC(rpc *RPC, p peer.ID)
// DropRPC is invoked when an outbound RPC is dropped, typically because of a queue full.
DropRPC(rpc *RPC, p peer.ID)
}

// pubsub tracer details
Expand Down Expand Up @@ -243,6 +249,10 @@ func (t *pubsubTracer) RecvRPC(rpc *RPC) {
return
}

for _, tr := range t.raw {
tr.RecvRPC(rpc)
}

if t.tracer == nil {
return
}
Expand All @@ -266,6 +276,10 @@ func (t *pubsubTracer) SendRPC(rpc *RPC, p peer.ID) {
return
}

for _, tr := range t.raw {
tr.SendRPC(rpc, p)
}

if t.tracer == nil {
return
}
Expand All @@ -289,6 +303,10 @@ func (t *pubsubTracer) DropRPC(rpc *RPC, p peer.ID) {
return
}

for _, tr := range t.raw {
tr.DropRPC(rpc, p)
}

if t.tracer == nil {
return
}
Expand Down

0 comments on commit 50b1cfa

Please sign in to comment.