diff --git a/log/sockstatlog/logger.go b/log/sockstatlog/logger.go index 167a37e46..293023d15 100644 --- a/log/sockstatlog/logger.go +++ b/log/sockstatlog/logger.go @@ -125,6 +125,7 @@ func NewLogger(logdir string, logf logger.Logf, logID logid.PublicID) (*Logger, HTTPC: &http.Client{Transport: logger.tr}, }, logf) + logger.logger.SetSockstatsLabel(sockstats.LabelSockstatlogLogger) return logger, nil } diff --git a/net/sockstats/label_string.go b/net/sockstats/label_string.go index 83baaf785..2c3fb6bd7 100644 --- a/net/sockstats/label_string.go +++ b/net/sockstats/label_string.go @@ -18,11 +18,13 @@ func _() { _ = x[LabelPortmapperClient-7] _ = x[LabelMagicsockConnUDP4-8] _ = x[LabelMagicsockConnUDP6-9] + _ = x[LabelNetlogLogger-10] + _ = x[LabelSockstatlogLogger-11] } -const _Label_name = "ControlClientAutoControlClientDialerDERPHTTPClientLogtailLoggerDNSForwarderDoHDNSForwarderUDPNetcheckClientPortmapperClientMagicsockConnUDP4MagicsockConnUDP6" +const _Label_name = "ControlClientAutoControlClientDialerDERPHTTPClientLogtailLoggerDNSForwarderDoHDNSForwarderUDPNetcheckClientPortmapperClientMagicsockConnUDP4MagicsockConnUDP6NetlogLoggerSockstatlogLogger" -var _Label_index = [...]uint8{0, 17, 36, 50, 63, 78, 93, 107, 123, 140, 157} +var _Label_index = [...]uint8{0, 17, 36, 50, 63, 78, 93, 107, 123, 140, 157, 169, 186} func (i Label) String() string { if i >= Label(len(_Label_index)-1) { diff --git a/net/sockstats/sockstats.go b/net/sockstats/sockstats.go index ebfc45962..050844d3b 100644 --- a/net/sockstats/sockstats.go +++ b/net/sockstats/sockstats.go @@ -38,16 +38,18 @@ type SockStat struct { // Labels are named after the package and function/struct that uses the socket. // Values may be persisted and thus existing entries should not be re-numbered. const ( - LabelControlClientAuto Label = 0 // control/controlclient/auto.go - LabelControlClientDialer Label = 1 // control/controlhttp/client.go - LabelDERPHTTPClient Label = 2 // derp/derphttp/derphttp_client.go - LabelLogtailLogger Label = 3 // logtail/logtail.go - LabelDNSForwarderDoH Label = 4 // net/dns/resolver/forwarder.go - LabelDNSForwarderUDP Label = 5 // net/dns/resolver/forwarder.go - LabelNetcheckClient Label = 6 // net/netcheck/netcheck.go - LabelPortmapperClient Label = 7 // net/portmapper/portmapper.go - LabelMagicsockConnUDP4 Label = 8 // wgengine/magicsock/magicsock.go - LabelMagicsockConnUDP6 Label = 9 // wgengine/magicsock/magicsock.go + LabelControlClientAuto Label = 0 // control/controlclient/auto.go + LabelControlClientDialer Label = 1 // control/controlhttp/client.go + LabelDERPHTTPClient Label = 2 // derp/derphttp/derphttp_client.go + LabelLogtailLogger Label = 3 // logtail/logtail.go + LabelDNSForwarderDoH Label = 4 // net/dns/resolver/forwarder.go + LabelDNSForwarderUDP Label = 5 // net/dns/resolver/forwarder.go + LabelNetcheckClient Label = 6 // net/netcheck/netcheck.go + LabelPortmapperClient Label = 7 // net/portmapper/portmapper.go + LabelMagicsockConnUDP4 Label = 8 // wgengine/magicsock/magicsock.go + LabelMagicsockConnUDP6 Label = 9 // wgengine/magicsock/magicsock.go + LabelNetlogLogger Label = 10 // wgengine/netlog/logger.go + LabelSockstatlogLogger Label = 11 // log/sockstatlog/logger.go ) // WithSockStats instruments a context so that sockets created with it will diff --git a/wgengine/netlog/logger.go b/wgengine/netlog/logger.go index 192d46810..bb3f667a3 100644 --- a/wgengine/netlog/logger.go +++ b/wgengine/netlog/logger.go @@ -19,6 +19,7 @@ "tailscale.com/logpolicy" "tailscale.com/logtail" "tailscale.com/net/connstats" + "tailscale.com/net/sockstats" "tailscale.com/net/tsaddr" "tailscale.com/smallzstd" "tailscale.com/tailcfg" @@ -121,6 +122,7 @@ func (nl *Logger) Startup(nodeID tailcfg.StableNodeID, nodeLogID, domainLogID lo IncludeProcID: true, IncludeProcSequence: true, }, log.Printf) + nl.logger.SetSockstatsLabel(sockstats.LabelNetlogLogger) // Startup a data structure to track per-connection statistics. // There is a maximum size for individual log messages that logtail