add meta packet statistics (#230)
This change add more metrics around "meta" (non "message" type packets). For lighthouse packets, we also record statistics around the specific lighthouse meta type. We don't keep statistics for the "message" type so that we don't slow down the fast path (and you can just look at metrics on the tun interface to find that information).
This commit is contained in:
@ -30,6 +30,7 @@ type HostMap struct {
|
||||
vpnCIDR *net.IPNet
|
||||
defaultRoute uint32
|
||||
unsafeRoutes *CIDRTree
|
||||
metricsEnabled bool
|
||||
}
|
||||
|
||||
type HostInfo struct {
|
||||
@ -384,8 +385,16 @@ func (hm *HostMap) PunchList() []*udpAddr {
|
||||
}
|
||||
|
||||
func (hm *HostMap) Punchy(conn *udpConn) {
|
||||
var metricsTxPunchy metrics.Counter
|
||||
if hm.metricsEnabled {
|
||||
metricsTxPunchy = metrics.GetOrRegisterCounter("messages.tx.punchy", nil)
|
||||
} else {
|
||||
metricsTxPunchy = metrics.NilCounter{}
|
||||
}
|
||||
|
||||
for {
|
||||
for _, addr := range hm.PunchList() {
|
||||
metricsTxPunchy.Inc(1)
|
||||
conn.WriteTo([]byte{1}, addr)
|
||||
}
|
||||
time.Sleep(time.Second * 30)
|
||||
|
Reference in New Issue
Block a user