Adjust clock skew logging thresholds.

Previous threshold (1ms for warning logs) is still too spammy.

Now we only log at warning for deltas above 5ms. Deltas between 1ms and 5ms
are logged at info.

PiperOrigin-RevId: 658859819
This commit is contained in:
Nicolas Lacasse
2024-08-02 11:59:30 -07:00
committed by gVisor bot
parent 0184ec4aac
commit 8f3c85d0aa
+9 -4
View File
@@ -229,10 +229,15 @@ func errorAdjust(prevParams Parameters, newParams Parameters, now TSCValue) (Par
// The log level is determined by the error severity.
func logErrorAdjustment(clock ClockID, errorNS ReferenceNS, orig, adjusted Parameters) {
magNS := int64(errorNS.Magnitude())
if magNS <= time.Millisecond.Nanoseconds() {
// Don't log small errors.
switch {
case magNS < time.Millisecond.Nanoseconds():
// Less than a millisecond. Too small to care.
return
case magNS < 5*time.Millisecond.Nanoseconds():
// Less than 5 milliseconds. Log at info.
log.Infof("Clock(%v): error: %v ns, adjusted frequency from %v Hz to %v Hz", clock, errorNS, orig.Frequency, adjusted.Frequency)
default:
// More than 5 milliseconds. This is getting interesting. Log at warning.
log.Warningf("Clock(%v): error: %v ns, adjusted frequency from %v Hz to %v Hz", clock, errorNS, orig.Frequency, adjusted.Frequency)
}
log.Warningf("Clock(%v): error: %v ns, adjusted frequency from %v Hz to %v Hz", clock, errorNS, orig.Frequency, adjusted.Frequency)
}