Documentation
¶
Overview ¶
Package sockstatlog provides a logger for capturing network socket stats for debugging. Stats are collected at a frequency of 10 Hz and logged to disk. Stats are only uploaded to the log server on demand.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SockstatLogID ¶ added in v1.40.0
SockstatLogID reproducibly derives a new logid.PrivateID for sockstat logging from a node's public backend log ID. The returned PrivateID is the sha256 sum of logID + "sockstat". If a node's public log ID becomes known, it is trivial to spoof sockstat logs for that node. Given that this is just for debugging, we're not too concerned about that.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger logs statistics about network sockets.
func NewLogger ¶
func NewLogger(logdir string, logf logger.Logf, logID logid.PublicID, netMon *netmon.Monitor, health *health.Tracker) (*Logger, error)
NewLogger returns a new Logger that will store stats in logdir. On platforms that do not support sockstat logging, a nil Logger will be returned. The returned Logger is not yet enabled, and must be shut down with Shutdown when it is no longer needed. Logs will be uploaded to the log server using a new log ID derived from the provided backend logID.
The netMon parameter is optional. It should be specified in environments where Tailscaled is manipulating the routing table.
func (*Logger) Flush ¶ added in v1.40.0
func (l *Logger) Flush()
Flush sends pending logs to the log server and flushes them from the local buffer.
func (*Logger) SetLoggingEnabled ¶ added in v1.40.0
SetLoggingEnabled enables or disables logging. When disabled, socket stats are not polled and no new logs are written to disk. Existing logs can still be fetched via the C2N API.