forked from LBRYCommunity/lbry-sdk
add counter for peers with colliding bytes
This commit is contained in:
parent
ff36bdc802
commit
06e94640b5
1 changed files with 8 additions and 1 deletions
|
@ -4,7 +4,7 @@ import logging
|
||||||
import typing
|
import typing
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from prometheus_client import Gauge
|
from prometheus_client import Gauge, Counter
|
||||||
|
|
||||||
from lbry.dht import constants
|
from lbry.dht import constants
|
||||||
from lbry.dht.protocol.distance import Distance
|
from lbry.dht.protocol.distance import Distance
|
||||||
|
@ -22,6 +22,10 @@ class KBucket:
|
||||||
"peers_in_routing_table", "Number of peers on routing table", namespace="dht_node",
|
"peers_in_routing_table", "Number of peers on routing table", namespace="dht_node",
|
||||||
labelnames=("scope",)
|
labelnames=("scope",)
|
||||||
)
|
)
|
||||||
|
peer_with_x_byte_colliding_metric = Counter(
|
||||||
|
"peer_x_byte_colliding", "Number of peers with at least X bytes colliding with this node id",
|
||||||
|
namespace="dht_node", labelnames=("amount",)
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, peer_manager: 'PeerManager', range_min: int, range_max: int, node_id: bytes):
|
def __init__(self, peer_manager: 'PeerManager', range_min: int, range_max: int, node_id: bytes):
|
||||||
"""
|
"""
|
||||||
|
@ -66,6 +70,9 @@ class KBucket:
|
||||||
if len(self.peers) < constants.K:
|
if len(self.peers) < constants.K:
|
||||||
self.peers.append(peer)
|
self.peers.append(peer)
|
||||||
self.peer_in_routing_table_metric.labels("global").inc()
|
self.peer_in_routing_table_metric.labels("global").inc()
|
||||||
|
if self._node_id[0] == peer.node_id[0]:
|
||||||
|
amount = 2 if self._node_id[1] == peer.node_id[1] else 1
|
||||||
|
self.peer_with_x_byte_colliding_metric.labels(amount=amount).inc()
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue