Skip to content

Commit

Permalink
Fix up sync client request logs (#770)
Browse files Browse the repository at this point in the history
* Fix up sync client request logs

* Handle empty node id on request error in sync client logs

* Nit: pre-allocate capacity for log ctx based
  • Loading branch information
aaronbuchwald authored May 24, 2022
1 parent 225c141 commit 9fb7a20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions peer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ func (c *client) RequestAny(minVersion version.Application, request []byte) ([]b
waitingHandler := newWaitingResponseHandler()
nodeID, err := c.network.RequestAny(minVersion, request, waitingHandler)
if err != nil {
return nil, ids.EmptyNodeID, err
return nil, nodeID, err
}
response := <-waitingHandler.responseChan
if waitingHandler.failed {
return nil, ids.EmptyNodeID, ErrRequestFailed
return nil, nodeID, ErrRequestFailed
}
return response, nodeID, nil
}
Expand Down
7 changes: 6 additions & 1 deletion sync/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ func (c *client) get(request message.Request, parseFn parseResponseFn) (interfac
metric.UpdateRequestLatency(time.Since(start))

if err != nil {
log.Info("request failed, retrying", "nodeID", nodeID, "attempt", attempt, "request", request, "err", err)
ctx := make([]interface{}, 0, 8)
if nodeID != ids.EmptyNodeID {
ctx = append(ctx, "nodeID", nodeID)
}
ctx = append(ctx, "attempt", attempt, "request", request, "err", err)
log.Debug("request failed, retrying", ctx...)
metric.IncFailed()
continue
} else {
Expand Down

0 comments on commit 9fb7a20

Please sign in to comment.