Track posted message type counts
This commit is contained in:
parent
317783091d
commit
26fa2c4af8
@ -71,6 +71,8 @@ var (
|
|||||||
receivedMessageTypes = expvar.NewMap("receivedMessageTypes")
|
receivedMessageTypes = expvar.NewMap("receivedMessageTypes")
|
||||||
receivedKeepalives = expvar.NewInt("receivedKeepalives")
|
receivedKeepalives = expvar.NewInt("receivedKeepalives")
|
||||||
supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages")
|
supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages")
|
||||||
|
postedMessageTypes = expvar.NewMap("postedMessageTypes")
|
||||||
|
postedKeepalives = expvar.NewInt("postedKeepalives")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/anacrolix/missinggo"
|
"github.com/anacrolix/missinggo"
|
||||||
@ -258,6 +259,7 @@ func (c *connection) PeerHasPiece(piece int) bool {
|
|||||||
func (c *connection) Post(msg pp.Message) {
|
func (c *connection) Post(msg pp.Message) {
|
||||||
select {
|
select {
|
||||||
case c.post <- msg:
|
case c.post <- msg:
|
||||||
|
postedMessageTypes.Add(strconv.FormatInt(int64(msg.Type), 10), 1)
|
||||||
case <-c.closed.C():
|
case <-c.closed.C():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,6 +494,7 @@ func (conn *connection) writeOptimizer(keepAliveDelay time.Duration) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
pending.PushBack(pp.Message{Keepalive: true})
|
pending.PushBack(pp.Message{Keepalive: true})
|
||||||
|
postedKeepalives.Add(1)
|
||||||
case msg, ok := <-conn.post:
|
case msg, ok := <-conn.post:
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user