From 3a689800880d42f656907df019757f4eb4f398b2 Mon Sep 17 00:00:00 2001 From: Matilda Clerke Date: Fri, 11 Oct 2024 15:57:44 +1100 Subject: [PATCH] 7311: Fix up inflight requests gauge in PeerTaskExecutor Signed-off-by: Matilda Clerke --- .../eth/manager/peertask/PeerTaskExecutor.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java index 6fee0a0577..2653fd6f35 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java @@ -120,10 +120,13 @@ public class PeerTaskExecutor { final PeerTask peerTask, final EthPeer peer) { String taskClassName = peerTask.getClass().getSimpleName(); AtomicInteger inflightRequestCountForThisTaskClass = - inflightRequestCountByClassName.getOrDefault(taskClassName, new AtomicInteger(0)); - if (!inflightRequestGauge.isLabelsObserved(taskClassName)) { - inflightRequestGauge.labels(inflightRequestCountForThisTaskClass::get, taskClassName); - } + inflightRequestCountByClassName.computeIfAbsent( + taskClassName, + (k) -> { + AtomicInteger inflightRequests = new AtomicInteger(0); + inflightRequestGauge.labels(inflightRequests::get, taskClassName); + return inflightRequests; + }); MessageData requestMessageData = peerTask.getRequestMessage(); PeerTaskExecutorResult executorResult; int retriesRemaining = peerTask.getRetriesWithSamePeer();