-
Notifications
You must be signed in to change notification settings - Fork 299
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
refactored logging for inclusion on gossip channels. #8733
Changes from 5 commits
f0e7ad4
4985d4d
40602d1
ec2c8f0
61b25de
f75b9e1
f9fe500
5ccd460
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ | |
|
||
package tech.pegasys.teku.networking.eth2.gossip; | ||
|
||
import io.libp2p.core.SemiDuplexNoOutboundStreamException; | ||
import io.libp2p.pubsub.MessageAlreadySeenException; | ||
import io.libp2p.pubsub.NoPeersForOutboundMessageException; | ||
import org.junit.jupiter.api.Test; | ||
import tech.pegasys.infrastructure.logging.LogCaptor; | ||
import tech.pegasys.teku.infrastructure.unsigned.UInt64; | ||
|
@@ -43,7 +43,7 @@ void shouldLogAlreadySeenErrorsAtDebugLevel() { | |
void shouldLogFirstNoPeersErrorsAtWarningLevel() { | ||
try (final LogCaptor logCaptor = LogCaptor.forClass(GossipFailureLogger.class)) { | ||
logger.logWithSuppression( | ||
new RuntimeException("Foo", new NoPeersForOutboundMessageException("So Lonely")), SLOT); | ||
new RuntimeException("Foo", new SemiDuplexNoOutboundStreamException("So Lonely")), SLOT); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this SemiDuplex exception used to share implementation with NoPeers error handling so this still tests the same thing and all the logic continues to work. |
||
logCaptor.assertWarnLog(NO_PEERS_MESSAGE); | ||
} | ||
} | ||
|
@@ -52,12 +52,12 @@ void shouldLogFirstNoPeersErrorsAtWarningLevel() { | |
void shouldLogRepeatedNoPeersErrorsAtDebugLevel() { | ||
try (final LogCaptor logCaptor = LogCaptor.forClass(GossipFailureLogger.class)) { | ||
logger.logWithSuppression( | ||
new RuntimeException("Foo", new NoPeersForOutboundMessageException("So Lonely")), SLOT); | ||
new RuntimeException("Foo", new SemiDuplexNoOutboundStreamException("So Lonely")), SLOT); | ||
logCaptor.clearLogs(); | ||
|
||
logger.logWithSuppression( | ||
new IllegalStateException( | ||
"Foo", new NoPeersForOutboundMessageException("Not a friend in the world")), | ||
"Foo", new SemiDuplexNoOutboundStreamException("Not a friend in the world")), | ||
SLOT); | ||
logCaptor.assertDebugLog(NO_PEERS_MESSAGE); | ||
} | ||
|
@@ -67,12 +67,12 @@ void shouldLogRepeatedNoPeersErrorsAtDebugLevel() { | |
void shouldLogNoPeersErrorsWithDifferentSlotsAtWarnLevel() { | ||
try (final LogCaptor logCaptor = LogCaptor.forClass(GossipFailureLogger.class)) { | ||
logger.logWithSuppression( | ||
new RuntimeException("Foo", new NoPeersForOutboundMessageException("So Lonely")), SLOT); | ||
new RuntimeException("Foo", new SemiDuplexNoOutboundStreamException("So Lonely")), SLOT); | ||
logCaptor.assertWarnLog(NO_PEERS_MESSAGE); | ||
|
||
logger.logWithSuppression( | ||
new IllegalStateException( | ||
"Foo", new NoPeersForOutboundMessageException("Not a friend in the world")), | ||
"Foo", new SemiDuplexNoOutboundStreamException("Not a friend in the world")), | ||
UInt64.valueOf(2)); | ||
logCaptor.assertWarnLog(noPeersMessage(2)); | ||
} | ||
|
@@ -82,15 +82,15 @@ void shouldLogNoPeersErrorsWithDifferentSlotsAtWarnLevel() { | |
void shouldLogNoPeersErrorsAtWarnLevelWhenSeparatedByADifferentException() { | ||
try (final LogCaptor logCaptor = LogCaptor.forClass(GossipFailureLogger.class)) { | ||
logger.logWithSuppression( | ||
new RuntimeException("Foo", new NoPeersForOutboundMessageException("So Lonely")), SLOT); | ||
new RuntimeException("Foo", new SemiDuplexNoOutboundStreamException("So Lonely")), SLOT); | ||
logCaptor.assertWarnLog(NO_PEERS_MESSAGE); | ||
logCaptor.clearLogs(); | ||
|
||
logger.logWithSuppression(new MessageAlreadySeenException("Dupe"), SLOT); | ||
|
||
logger.logWithSuppression( | ||
new IllegalStateException( | ||
"Foo", new NoPeersForOutboundMessageException("Not a friend in the world")), | ||
"Foo", new SemiDuplexNoOutboundStreamException("Not a friend in the world")), | ||
SLOT); | ||
logCaptor.assertWarnLog(NO_PEERS_MESSAGE); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
package tech.pegasys.teku.networking.p2p.libp2p.gossip; | ||
|
||
import com.google.common.base.Throwables; | ||
import io.libp2p.core.pubsub.MessageApi; | ||
import io.libp2p.core.pubsub.PubsubPublisherApi; | ||
import io.libp2p.core.pubsub.Topic; | ||
|
@@ -87,6 +88,10 @@ public void gossip(final Bytes bytes) { | |
SafeFuture.of(publisher.publish(Unpooled.wrappedBuffer(bytes.toArrayUnsafe()), topic)) | ||
.finish( | ||
() -> LOG.trace("Successfully gossiped message on {}", topic), | ||
err -> LOG.debug("Failed to gossip message on " + topic, err)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the full stack here got pretty unusable pretty quickly. |
||
err -> | ||
LOG.debug( | ||
"Failed to gossip message on {}, {}", | ||
topic, | ||
Throwables.getRootCause(err).getMessage())); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to me the message for
NoPeersForOutboundMessageException
. And the above seems a more generic one so matchingSemiDuplexNoOutboundStreamException