Skip to content

Commit

Permalink
Remove excess bytes in logging (not necessary to log payload) (#9711)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsondav authored Jun 27, 2023
1 parent 52c55cc commit e4e6475
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions core/services/relay/evm/mercury/transmitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (mt *mercuryTransmitter) runloop() {
return
} else if err != nil {
mt.transmitConnectionErrorCount.Inc()
mt.lggr.Errorw("Transmit report failed", "req", t.Req, "error", err, "reportCtx", t.ReportCtx)
mt.lggr.Errorw("Transmit report failed", "error", err, "reportCtx", t.ReportCtx)
if ok := mt.queue.Push(t.Req, t.ReportCtx); !ok {
mt.lggr.Error("Failed to push report to transmit queue; queue is closed")
return
Expand Down Expand Up @@ -240,7 +240,7 @@ func (mt *mercuryTransmitter) runloop() {
}
}
transmitServerErrorCount.WithLabelValues(mt.feedIDHex, fmt.Sprintf("%d", res.Code)).Inc()
mt.lggr.Errorw("Transmit report failed; mercury server returned error", "unpackErr", unpackErr, "validFromBlock", validFrom, "currentBlock", currentBlock, "req", t.Req, "response", res, "reportCtx", t.ReportCtx, "err", res.Error, "code", res.Code)
mt.lggr.Errorw("Transmit report failed; mercury server returned error", "unpackErr", unpackErr, "validFromBlock", validFrom, "currentBlock", currentBlock, "response", res, "reportCtx", t.ReportCtx, "err", res.Error, "code", res.Code)
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions core/services/relay/evm/mercury/wsrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func newClient(lggr logger.Logger, clientPrivKey csakey.KeyV2, serverPubKey []by
csaKey: clientPrivKey,
serverPubKey: serverPubKey,
serverURL: serverURL,
logger: lggr.Named("WSRPC"),
logger: lggr.Named("WSRPC").With("mercuryServerURL", serverURL),
chResetTransport: make(chan struct{}, 1),
chStop: make(chan struct{}),
timeoutCountMetric: timeoutCount.WithLabelValues(serverURL),
Expand Down Expand Up @@ -235,8 +235,7 @@ func (w *client) waitForReady(ctx context.Context) (err error) {
}

func (w *client) Transmit(ctx context.Context, req *pb.TransmitRequest) (resp *pb.TransmitResponse, err error) {
lggr := w.logger.With("req.Payload", hexutil.Encode(req.Payload))
lggr.Trace("Transmit")
w.logger.Trace("Transmit")
start := time.Now()
if err = w.waitForReady(ctx); err != nil {
return nil, errors.Wrap(err, "Transmit failed")
Expand All @@ -246,7 +245,7 @@ func (w *client) Transmit(ctx context.Context, req *pb.TransmitRequest) (resp *p
w.timeoutCountMetric.Inc()
cnt := w.consecutiveTimeoutCnt.Add(1)
if cnt == MaxConsecutiveTransmitFailures {
lggr.Errorf("Timed out on %d consecutive transmits, resetting transport", cnt)
w.logger.Errorf("Timed out on %d consecutive transmits, resetting transport", cnt)
// NOTE: If we get 5+ request timeouts in a row, close and re-open
// the websocket connection.
//
Expand All @@ -266,17 +265,17 @@ func (w *client) Transmit(ctx context.Context, req *pb.TransmitRequest) (resp *p
// It should be safe to just ignore in this case.
//
// Debug log in case my reasoning is wrong.
lggr.Debugf("Transport is resetting, cnt=%d", cnt)
w.logger.Debugf("Transport is resetting, cnt=%d", cnt)
}
}
} else {
w.consecutiveTimeoutCnt.Store(0)
}
if err != nil {
lggr.Warnw("Transmit failed", "err", err, "req", req, "resp", resp)
w.logger.Warnw("Transmit failed", "err", err, "resp", resp)
incRequestStatusMetric(statusFailed)
} else {
lggr.Debugw("Transmit succeeded", "resp", resp)
w.logger.Debugw("Transmit succeeded", "resp", resp)
incRequestStatusMetric(statusSuccess)
setRequestLatencyMetric(float64(time.Since(start).Milliseconds()))
}
Expand All @@ -291,9 +290,9 @@ func (w *client) LatestReport(ctx context.Context, req *pb.LatestReportRequest)
}
resp, err = w.client.LatestReport(ctx, req)
if err != nil {
lggr.Errorw("LatestReport failed", "err", err, "req", req, "resp", resp)
lggr.Errorw("LatestReport failed", "err", err, "resp", resp)
} else if resp.Error != "" {
lggr.Errorw("LatestReport failed; mercury server returned error", "err", resp.Error, "req", req, "resp", resp)
lggr.Errorw("LatestReport failed; mercury server returned error", "err", resp.Error, "resp", resp)
} else {
lggr.Debugw("LatestReport succeeded", "resp", resp)
}
Expand Down

0 comments on commit e4e6475

Please sign in to comment.