dht: Add counters for writes and write errors

This commit is contained in:
Matt Joiner 2016-07-23 22:39:06 +10:00
parent 980cd69ab2
commit b98c1a7edc
2 changed files with 4 additions and 0 deletions

View File

@ -11,4 +11,6 @@ var (
readUnmarshalError = expvar.NewInt("dhtReadUnmarshalError")
readQuery = expvar.NewInt("dhtReadQuery")
announceErrors = expvar.NewInt("dhtAnnounceErrors")
writeErrors = expvar.NewInt("dhtWriteErrors")
writes = expvar.NewInt("dhtWrites")
)

View File

@ -382,7 +382,9 @@ func (s *Server) writeToNode(b []byte, node Addr) (err error) {
}
}
n, err := s.socket.WriteTo(b, node.UDPAddr())
writes.Add(1)
if err != nil {
writeErrors.Add(1)
err = fmt.Errorf("error writing %d bytes to %s: %s", len(b), node, err)
return
}