wgengine/magicsock: add more DERP home clientmetrics

Updates tailscale/corp#18095

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I423adca2de0730092394bb5fd5796cd35557d352
pull/12629/head
Andrew Dunham 5 months ago
parent a6b13e6972
commit 8487fd2ec2

@ -135,6 +135,7 @@ func (c *Conn) pickDERPFallback() int {
return pickDERPFallbackForTests() return pickDERPFallbackForTests()
} }
metricDERPHomeFallback.Add(1)
return ids[rands.IntN(uint64(uintptr(unsafe.Pointer(c))), len(ids))] return ids[rands.IntN(uint64(uintptr(unsafe.Pointer(c))), len(ids))]
} }
@ -173,6 +174,7 @@ func (c *Conn) maybeSetNearestDERP(report *netcheck.Report) (preferredDERP int)
myDerp := c.myDerp myDerp := c.myDerp
c.mu.Unlock() c.mu.Unlock()
if myDerp != 0 { if myDerp != 0 {
metricDERPHomeNoChangeNoControl.Add(1)
return myDerp return myDerp
} }
@ -948,6 +950,7 @@ func (c *Conn) cleanStaleDerp() {
} }
if ad.lastWrite.Before(tooOld) { if ad.lastWrite.Before(tooOld) {
c.closeDerpLocked(i, "idle") c.closeDerpLocked(i, "idle")
metricDERPStaleCleaned.Add(1)
dirty = true dirty = true
} else { } else {
someNonHomeOpen = true someNonHomeOpen = true

@ -3028,6 +3028,17 @@ var (
// changed from non-zero to a different non-zero. // changed from non-zero to a different non-zero.
metricDERPHomeChange = clientmetric.NewCounter("derp_home_change") metricDERPHomeChange = clientmetric.NewCounter("derp_home_change")
// metricDERPHomeNoChangeNoControl is how many times our DERP home
// region did not change because we didn't have an active connection to
// the control server.
metricDERPHomeNoChangeNoControl = clientmetric.NewCounter("derp_home_no_change_no_control")
// metricDERPHomeFallback is how many times we picked a DERP fallback.
metricDERPHomeFallback = clientmetric.NewCounter("derp_home_fallback")
// metricDERPStaleCleaned is how many times we closed a stale DERP connection.
metricDERPStaleCleaned = clientmetric.NewCounter("derp_stale_cleaned")
// Disco packets received bpf read path // Disco packets received bpf read path
//lint:ignore U1000 used on Linux only //lint:ignore U1000 used on Linux only
metricRecvDiscoPacketIPv4 = clientmetric.NewCounter("magicsock_disco_recv_bpf_ipv4") metricRecvDiscoPacketIPv4 = clientmetric.NewCounter("magicsock_disco_recv_bpf_ipv4")

Loading…
Cancel
Save