summaryrefslogtreecommitdiffhomepage
path: root/wgengine/userspace.go
diff options
context:
space:
mode:
authorjulianknodt <julianknodt@gmail.com>2021-08-17 13:10:57 -0700
committerjulianknodt <julianknodt@gmail.com>2021-08-20 12:04:28 -0700
commit4f1e783ad8e26543ec91668a20b25917987d0c4b (patch)
tree08d17442930b1d487e6ee7fd5c103cc99802ae49 /wgengine/userspace.go
parentb9bd7dbc5dda17b7b8abb938092aa0a625c27056 (diff)
downloadtailscale-jknodt/logging.tar.xz
tailscale-jknodt/logging.zip
wgengine: log connection metricsjknodt/logging
Adds counter for connection types, which aren't currently bubbled up anywhere but can be easily in the future. Signed-off-by: julianknodt <julianknodt@gmail.com>
Diffstat (limited to 'wgengine/userspace.go')
-rw-r--r--wgengine/userspace.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/wgengine/userspace.go b/wgengine/userspace.go
index 4a22c888a..820e40f0e 100644
--- a/wgengine/userspace.go
+++ b/wgengine/userspace.go
@@ -119,6 +119,8 @@ type userspaceEngine struct {
statusBufioReader *bufio.Reader // reusable for UAPI
lastStatusPollTime mono.Time // last time we polled the engine status
+ connMetrics metrics // counts for success/failure/kinds of connections.
+
mu sync.Mutex // guards following; see lock order comment below
netMap *netmap.NetworkMap // or nil
closing bool // Close was called (even if we're still closing)
@@ -133,6 +135,19 @@ type userspaceEngine struct {
// Lock ordering: magicsock.Conn.mu, wgLock, then mu.
}
+type metrics struct {
+ // offline is the number of flows magicsock attempted to connect to which are offline.
+ offline uint32
+ // relayed is the number of flows magicsock connected thru over DERP.
+ relayed uint32
+ // direct is the number of flows connected to directly.
+ direct uint32
+ // unreachable is the number of flows which were expected to be online but could not be
+ // connected to. This is expected to be small, as there is only a brief window where flows are
+ // offline but have not yet notified control.
+ unreachable uint32
+}
+
// InternalsGetter is implemented by Engines that can export their internals.
type InternalsGetter interface {
GetInternals() (_ *tstun.Wrapper, _ *magicsock.Conn, ok bool)