forked from LBRYCommunity/lbry-sdk
add passive estimation to prometheus
This commit is contained in:
parent
add147b409
commit
470ee72462
1 changed files with 7 additions and 0 deletions
|
@ -24,6 +24,10 @@ PEERS = Gauge(
|
||||||
"known_peers", "Number of peers on routing table", namespace="dht_node",
|
"known_peers", "Number of peers on routing table", namespace="dht_node",
|
||||||
labelnames=("method",)
|
labelnames=("method",)
|
||||||
)
|
)
|
||||||
|
ESTIMATED_SIZE = Gauge(
|
||||||
|
"passively_estimated_network_size", "Estimated network size from routing table", namespace="dht_node",
|
||||||
|
labelnames=("method",)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SimpleMetrics:
|
class SimpleMetrics:
|
||||||
|
@ -126,6 +130,9 @@ async def main(host: str, port: int, db_file_path: str, bootstrap_node: Optional
|
||||||
while True:
|
while True:
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
PEERS.labels('main').set(len(node.protocol.routing_table.get_peers()))
|
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()))
|
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.",
|
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),
|
len(node.protocol.routing_table.get_peers()), len(node.protocol.data_store),
|
||||||
|
|
Loading…
Reference in a new issue