From 32b95fa04ab538a48251123aa52b1a87ea48b29e Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 6 Dec 2021 11:40:35 -0300 Subject: [PATCH] add passive estimation to prometheus --- scripts/dht_node.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/dht_node.py b/scripts/dht_node.py index 2686b0e9d..945b8988b 100644 --- a/scripts/dht_node.py +++ b/scripts/dht_node.py @@ -24,6 +24,10 @@ PEERS = Gauge( "known_peers", "Number of peers on routing table", namespace="dht_node", labelnames=("method",) ) +ESTIMATED_SIZE = Gauge( + "passively_estimated_network_size", "Estimated network size from routing table", namespace="dht_node", + labelnames=("method",) +) class SimpleMetrics: @@ -126,6 +130,9 @@ async def main(host: str, port: int, db_file_path: str, bootstrap_node: Optional while True: await asyncio.sleep(10) PEERS.labels('main').set(len(node.protocol.routing_table.get_peers())) + peers = node.protocol.routing_table.get_peers() + close_ids = [peer for peer in peers if peer.node_id[0] == node.protocol.node_id[0]] + ESTIMATED_SIZE.labels('main').set(len(close_ids) * 256) BLOBS_STORED.labels('main').set(len(node.protocol.data_store.get_storing_contacts())) log.info("Known peers: %d. Storing contact information for %d blobs from %d peers.", len(node.protocol.routing_table.get_peers()), len(node.protocol.data_store),