Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][broker]Change the log level to reduce repeated error logs #23192

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.AllArgsConstructor;
Expand All @@ -54,7 +55,8 @@ public class LinuxInfoUtils {
// NIC type
private static final int ARPHRD_ETHER = 1;
private static final String NIC_SPEED_TEMPLATE = "/sys/class/net/%s/speed";

private static final long errLogPrintedFrequencyInReadingNicLimits = 1000;
private static final AtomicLong failedCounterInReadingNicLimits = new AtomicLong(0);
private static Object /*jdk.internal.platform.Metrics*/ metrics;
private static Method getMetricsProviderMethod;
private static Method getCpuQuotaMethod;
Expand Down Expand Up @@ -251,7 +253,15 @@ public static double getTotalNicLimit(List<String> nics, BitRateUnit bitRateUnit
try {
return readDoubleFromFile(getReplacedNICPath(NIC_SPEED_TEMPLATE, nicPath));
} catch (IOException e) {
log.error("[LinuxInfo] Failed to get total nic limit.", e);
// ERROR-level logs about NIC rate limiting reading failures are periodically printed but not
// continuously printed
if (failedCounterInReadingNicLimits.getAndIncrement() % errLogPrintedFrequencyInReadingNicLimits == 0) {
log.error("[LinuxInfo] Failed to get the nic limit of {}.", nicPath, e);
} else {
if (log.isDebugEnabled()) {
log.debug("[LinuxInfo] Failed to get the nic limit of {}.", nicPath, e);
}
}
return 0d;
}
}).sum(), BitRateUnit.Megabit);
Expand Down
Loading