7311: Modify PeerTaskExecutor metric to include response time from peer

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
pull/7628/head
Matilda Clerke 2 months ago
parent 96c803030c
commit b0f2ed024f
  1. 9
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java

@ -50,7 +50,7 @@ public class PeerTaskExecutor {
metricsSystem.createLabelledTimer( metricsSystem.createLabelledTimer(
BesuMetricCategory.PEERS, BesuMetricCategory.PEERS,
"PeerTaskExecutor:RequestTime", "PeerTaskExecutor:RequestTime",
"Time taken to send a request", "Time taken to send a request and receive a response",
"className"); "className");
} }
@ -95,13 +95,14 @@ public class PeerTaskExecutor {
do { do {
try { try {
MessageData responseMessageData; T result ;
try (final OperationTimer.TimingContext timingContext = try (final OperationTimer.TimingContext timingContext =
requestTimer.labels(peerTask.getClass().getSimpleName()).startTimer()) { requestTimer.labels(peerTask.getClass().getSimpleName()).startTimer()) {
responseMessageData = MessageData responseMessageData =
requestSender.sendRequest(peerTask.getSubProtocol(), requestMessageData, peer); requestSender.sendRequest(peerTask.getSubProtocol(), requestMessageData, peer);
result = peerTask.parseResponse(responseMessageData);
} }
T result = peerTask.parseResponse(responseMessageData);
peer.recordUsefulResponse(); peer.recordUsefulResponse();
executorResult = new PeerTaskExecutorResult<>(result, PeerTaskExecutorResponseCode.SUCCESS); executorResult = new PeerTaskExecutorResult<>(result, PeerTaskExecutorResponseCode.SUCCESS);

Loading…
Cancel
Save