Less Noisy P2P Logs (#5607)

* fix logging issues
* change again
* fix errors
* Merge refs/heads/master into lessNoisy
* gaz
* Merge branch 'lessNoisy' of https://github.com/prysmaticlabs/geth-sharding into lessNoisy
This commit is contained in:
Nishant Das 2020-04-24 12:10:53 +08:00 committed by GitHub
parent 921263848a
commit f9eb54661a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 10 deletions

View File

@ -18,7 +18,6 @@ go_library(
"@com_github_golang_snappy//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
)

View File

@ -10,7 +10,6 @@ import (
errors "github.com/pkg/errors"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/sirupsen/logrus"
)
var _ = NetworkEncoding(&SszNetworkEncoder{})
@ -192,10 +191,9 @@ func (e SszNetworkEncoder) MaxLength(length int) int {
// Writes a bytes value through a snappy buffered writer.
func writeSnappyBuffer(w io.Writer, b []byte) (int, error) {
bufWriter := snappy.NewBufferedWriter(w)
defer func() {
if err := bufWriter.Close(); err != nil {
logrus.WithError(err).Error("Failed to close snappy buffered writer")
}
}()
return bufWriter.Write(b)
num, err := bufWriter.Write(b)
if err != nil {
return 0, err
}
return num, bufWriter.Close()
}

View File

@ -31,7 +31,7 @@ func (s *Service) AddConnectionHandler(reqFunc func(ctx context.Context, id peer
go func() {
log.WithField("reason", "at peer limit").Trace("Ignoring connection request")
if err := goodbyeFunc(context.Background(), conn.RemotePeer()); err != nil {
log.WithError(err).Error("Unable to send goodbye message to peer")
log.WithError(err).Trace("Unable to send goodbye message to peer")
}
if err := s.Disconnect(conn.RemotePeer()); err != nil {
log.WithError(err).Error("Unable to disconnect from peer")

View File

@ -110,6 +110,12 @@ func (r *Service) registerRPC(topic string, base interface{}, handle rpcHandler)
if t.Kind() == reflect.Ptr {
msg := reflect.New(t.Elem())
if err := r.p2p.Encoding().DecodeWithLength(stream, msg.Interface()); err != nil {
// Debug logs for goodbye/status errors
if strings.Contains(topic, p2p.RPCGoodByeTopic) || strings.Contains(topic, p2p.RPCStatusTopic) {
log.WithError(err).Debug("Failed to decode goodbye stream message")
traceutil.AnnotateError(span, err)
return
}
log.WithError(err).Warn("Failed to decode stream message")
traceutil.AnnotateError(span, err)
return

View File

@ -34,7 +34,7 @@ func (r *Service) maintainPeerStatuses() {
}
if roughtime.Now().After(lastUpdated.Add(interval)) {
if err := r.reValidatePeer(r.ctx, id); err != nil {
log.WithField("peer", id).WithError(err).Error("Failed to reValidate peer")
log.WithField("peer", id).WithError(err).Error("Failed to revalidate peer")
}
}
}(pid)