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

throttled regular log of peers list at debug and trace #6823

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.eth.manager;

import static com.google.common.base.Preconditions.checkArgument;
import static org.hyperledger.besu.util.log.LogUtil.throttledLog;

import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.chain.Blockchain;
Expand Down Expand Up @@ -79,6 +80,10 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
private final BlockBroadcaster blockBroadcaster;
private final List<PeerValidator> peerValidators;
private final Optional<MergePeerFilter> mergePeerFilter;
private final AtomicBoolean logDebug = new AtomicBoolean(true);
private final int logDebugRepeatDelay = 120;
private final AtomicBoolean logTrace = new AtomicBoolean(true);
private final int logTraceRepeatDelay = 15;

public EthProtocolManager(
final Blockchain blockchain,
Expand Down Expand Up @@ -392,7 +397,10 @@ public void handleNewConnection(final PeerConnection connection) {
} catch (final PeerNotConnected peerNotConnected) {
// Nothing to do.
}
LOG.atTrace().setMessage("{}").addArgument(ethPeers::toString).log();
throttledLog(
LOG::trace, String.format("Current peers: %s", ethPeers), logTrace, logTraceRepeatDelay);
throttledLog(
LOG::debug, String.format("Current peers: %s", ethPeers), logDebug, logDebugRepeatDelay);
}

@Override
Expand Down Expand Up @@ -426,7 +434,10 @@ public void handleDisconnect(
.addArgument(() -> connection.getPeer().getLoggableId())
.addArgument(ethPeers::peerCount)
.log();
LOG.atTrace().setMessage("{}").addArgument(ethPeers::toString).log();
throttledLog(
LOG::trace, String.format("Current peers: %s", ethPeers), logTrace, logTraceRepeatDelay);
throttledLog(
LOG::debug, String.format("Current peers: %s", ethPeers), logDebug, logDebugRepeatDelay);
}
}

Expand Down