WIP: add best guess prominent socket stats logging

This commit is contained in:
Phil Pennock
2020-10-13 19:45:02 -04:00
parent 331f6ca3aa
commit cceeb94166
3 changed files with 26 additions and 0 deletions

View File

@@ -4521,6 +4521,8 @@ func (c *client) diagnosticsLoop() {
} }
return return
} }
// Log before populate, so that the previous metrics are available.
(&c.diagTCPData).LogInteresting(c, routeID, &c.diagMetrics)
(&c.diagMetrics).PopulateFromTCPDiagnostics(&c.diagTCPData, expvarMaps, routeID) (&c.diagMetrics).PopulateFromTCPDiagnostics(&c.diagTCPData, expvarMaps, routeID)
c.mu.Unlock() c.mu.Unlock()
} }
@@ -4555,3 +4557,8 @@ func (c *client) Warnf(format string, v ...interface{}) {
format = fmt.Sprintf("%s - %s", c, format) format = fmt.Sprintf("%s - %s", c, format)
c.srv.Warnf(format, v...) c.srv.Warnf(format, v...)
} }
func (c *client) Fatalf(format string, v ...interface{}) {
format = fmt.Sprintf("%s - %s", c, format)
c.srv.Fatalf(format, v...)
}

View File

@@ -170,3 +170,20 @@ func populateExpvarMapsTCPDiagnostics(maps *TCPInfoExpMaps, fullLabel string, me
vm.Field(i).Interface().(*expvar.Map).Set(fullLabel, vmetrics.FieldByName(tm.Field(i).Name)) vm.Field(i).Interface().(*expvar.Map).Set(fullLabel, vmetrics.FieldByName(tm.Field(i).Name))
} }
} }
func (d *TCPDiagnostics) LogInteresting(log Logger, fullLabel string, previous *TCPInfoExpMetrics) {
if int64(d.Info.Pmtu) != previous.PathMTU.Value() {
log.Noticef("[SOCKET-DIAGNOSTICS] %q: Path MTU change: was %v now %v",
fullLabel, previous.PathMTU.Value(), d.Info.Pmtu)
}
if int64(d.Info.Lost) != previous.LostPackets.Value() {
v := previous.LostPackets.Value()
log.Warnf("[SOCKET-DIAGNOSTICS] %q: LOST PACKETS: was %v now %v INCREASE: %v",
fullLabel, v, int64(d.Info.Lost), v-int64(d.Info.Lost))
}
if int64(d.Info.Total_retrans) != previous.TotalRetransPackets.Value() {
v := previous.TotalRetransPackets.Value()
log.Warnf("[SOCKET-DIAGNOSTICS] %q: total retransmission increase: was %v now %v INCREASE: %v",
fullLabel, v, int64(d.Info.Total_retrans), v-int64(d.Info.Total_retrans))
}
}

View File

@@ -45,4 +45,6 @@ func NewTCPInfoExpMaps() *TCPInfoExpMaps {
return &TCPInfoExpMaps{} return &TCPInfoExpMaps{}
} }
func (d *TCPDiagnostics) LogInteresting(log Logger, fullLabel string, previous *TCPInfoExpMetrics) {}
// There will be other functions here, as we populate maps. // There will be other functions here, as we populate maps.