Skip to content

Commit 66fd7d6

Browse files
committed
chore: remove redundancies
1 parent 3bfce78 commit 66fd7d6

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

docs/examples.metrics.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ start the prometheus and grafana dashboards. For this create a `docker-compose.y
6565
depends_on:
6666
- prometheus
6767
68+
And a `prometheus.yml` file like this:
69+
70+
.. code-block:: console
71+
72+
global:
73+
scrape_interval: 5s
74+
75+
scrape_configs:
76+
- job_name: "libp2p-python"
77+
static_configs:
78+
- targets:
79+
- "host.docker.internal:8000"
80+
81+
6882
And run it like this
6983
.. code-block:: console
7084
@@ -73,6 +87,7 @@ And run it like this
7387
A similar file is present in `py-libp2p/libp2p/metrics` directory also, so either create a new docker-compose
7488
file or run it from the above path. This basically starts a prometheus and grafana server in your localhost,
7589
with which the metrics can be viewed in graph format.
90+
Remember that the dashboards will be created for the node, whose prometheus metric-server is running on port `8000`.
7691

7792
Now see how to communicate between the 2 nodes, via Pubsub/Gossipsub, Ping and Kad-DHT
7893

examples/metrics/coordinator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020
Available commands:
2121
- connect <multiaddr> - Connect to another peer
2222
- ping <maddr> <count> - Ping to another peer
23+
24+
GOSSIPSUB
2325
- join <topic> - Subscribe to a topic
2426
- leave <topic> - Unsubscribe to a topic
2527
- publish <topic> <message> - Publish a message
28+
29+
KAD-DHT
2630
- put <key> <value> - Execute PUT_VALUE in DHT
2731
- get <key> - Execute GET_VALUE in DHT
2832
- advertize <content-id> - Execute ADD_PROVIDER in DHT
2933
- get_provider <content-id> - Execute GET_PROVIDERS in DHT
34+
3035
- local - List local multiaddr
3136
- help - List the existing commands
3237
- exit - Shut down

libp2p/metrics/kad_dht.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
from libp2p.kad_dht.kad_dht import KadDhtEvent
44

5-
# COUNTER
6-
7-
# INBOUND_REQ
8-
# FIND_NODE
9-
# GET_VALUE
10-
# PUT_VALUE
11-
# GET_PROVIDERS
12-
# ADD_PROVIDERS
13-
145

156
class KadDhtMetrics:
167
inbound: Counter

libp2p/metrics/swarm.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
from prometheus_client import Counter
22

3-
# METRICS
4-
5-
# conn_incoming
6-
# conn_incoming_error
7-
# dial_attemp
8-
# conn_outgoing_error
9-
103

114
class SwarmEvent:
125
peer_id: str | None = None

libp2p/pubsub/gossipsub.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878

7979
_MAX_PENDING_GRAFT_PRUNE_PER_PEER = 64
8080

81+
8182
class GossipSub(IPubsubRouter, Service):
8283
protocols: list[TProtocol]
8384
pubsub: Pubsub | None

tests/core/network/test_stream_semaphore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _mock_net_stream(swarm_conn: Mock | None = None) -> NetStream:
4444
muxed_stream.close = AsyncMock()
4545
muxed_stream.reset = AsyncMock()
4646

47-
ns = NetStream(muxed_stream, swarm_conn)
47+
ns = NetStream(muxed_stream, swarm_conn, None)
4848
return ns
4949

5050

0 commit comments

Comments
 (0)