From 7c926d20ae1b9a8cdba6a7c44a5d0817e86ff541 Mon Sep 17 00:00:00 2001 From: Stefan Pingel <16143240+pinges@users.noreply.github.com> Date: Thu, 13 Oct 2022 23:56:48 +1000 Subject: [PATCH] improve number of peers metric (#4527) Signed-off-by: Stefan --- .../org/hyperledger/besu/ethereum/eth/manager/EthPeers.java | 5 +++++ .../org/hyperledger/besu/ethereum/p2p/rlpx/RlpxAgent.java | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java index a942ced95a..7554a6cbe5 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java @@ -94,6 +94,11 @@ public class EthPeers { "pending_peer_requests_current", "Number of peer requests currently pending because peers are busy", pendingRequests::size); + metricsSystem.createIntegerGauge( + BesuMetricCategory.ETHEREUM, + "peer_count", + "The current number of peers connected", + () -> (int) streamAvailablePeers().count()); } public void registerConnection( diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/RlpxAgent.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/RlpxAgent.java index 81fe8ad7e8..5aa2ff3bff 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/RlpxAgent.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/RlpxAgent.java @@ -111,11 +111,6 @@ public class RlpxAgent { metricsSystem.createCounter( BesuMetricCategory.PEERS, "connected_total", "Total number of peers connected"); - metricsSystem.createIntegerGauge( - BesuMetricCategory.ETHEREUM, - "peer_count", - "The current number of peers connected", - this::getConnectionCount); metricsSystem.createIntegerGauge( BesuMetricCategory.ETHEREUM, "peer_limit",