diff --git a/client.go b/client.go index ad5ae2e0..663d1a01 100644 --- a/client.go +++ b/client.go @@ -71,6 +71,8 @@ var ( receivedMessageTypes = expvar.NewMap("receivedMessageTypes") receivedKeepalives = expvar.NewInt("receivedKeepalives") supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages") + postedMessageTypes = expvar.NewMap("postedMessageTypes") + postedKeepalives = expvar.NewInt("postedKeepalives") ) const ( diff --git a/connection.go b/connection.go index a3e6041a..a140e24c 100644 --- a/connection.go +++ b/connection.go @@ -10,6 +10,7 @@ import ( "fmt" "io" "net" + "strconv" "time" "github.com/anacrolix/missinggo" @@ -258,6 +259,7 @@ func (c *connection) PeerHasPiece(piece int) bool { func (c *connection) Post(msg pp.Message) { select { case c.post <- msg: + postedMessageTypes.Add(strconv.FormatInt(int64(msg.Type), 10), 1) case <-c.closed.C(): } } @@ -492,6 +494,7 @@ func (conn *connection) writeOptimizer(keepAliveDelay time.Duration) { break } pending.PushBack(pp.Message{Keepalive: true}) + postedKeepalives.Add(1) case msg, ok := <-conn.post: if !ok { return