diff options
author | Dmitry Shulyak <yashulyak@gmail.com> | 2018-05-29 19:46:09 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-05-29 19:46:09 +0800 |
commit | 7677ec1f3414c1e3712bf33598f8780c3b76742b (patch) | |
tree | 821fd6567acc495b35d35f73f4f12a67bb6894b7 /p2p/discv5/udp.go | |
parent | 84f8c0cc1fbe1ab9c128555392a82ba609820fef (diff) | |
download | go-tangerine-7677ec1f3414c1e3712bf33598f8780c3b76742b.tar.gz go-tangerine-7677ec1f3414c1e3712bf33598f8780c3b76742b.tar.zst go-tangerine-7677ec1f3414c1e3712bf33598f8780c3b76742b.zip |
p2p/discv5: add egress/ingress traffic metrics to discv5 udp transport (#16369)
Diffstat (limited to 'p2p/discv5/udp.go')
-rw-r--r-- | p2p/discv5/udp.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/p2p/discv5/udp.go b/p2p/discv5/udp.go index 09e5f8b37..49e1cb811 100644 --- a/p2p/discv5/udp.go +++ b/p2p/discv5/udp.go @@ -334,8 +334,10 @@ func (t *udp) sendPacket(toid NodeID, toaddr *net.UDPAddr, ptype byte, req inter return hash, err } log.Trace(fmt.Sprintf(">>> %v to %x@%v", nodeEvent(ptype), toid[:8], toaddr)) - if _, err = t.conn.WriteToUDP(packet, toaddr); err != nil { + if nbytes, err := t.conn.WriteToUDP(packet, toaddr); err != nil { log.Trace(fmt.Sprint("UDP send failed:", err)) + } else { + egressTrafficMeter.Mark(int64(nbytes)) } //fmt.Println(err) return hash, err @@ -374,6 +376,7 @@ func (t *udp) readLoop() { buf := make([]byte, 1280) for { nbytes, from, err := t.conn.ReadFromUDP(buf) + ingressTrafficMeter.Mark(int64(nbytes)) if netutil.IsTemporaryError(err) { // Ignore temporary read errors. log.Debug(fmt.Sprintf("Temporary read error: %v", err)) |