mirror of https://github.com/vacp2p/nim-libp2p.git
count published messages (#224)
This commit is contained in:
parent
224c2613e3
commit
fe828d87d8
|
@ -92,6 +92,7 @@ method rpcHandler*(f: FloodSub,
|
|||
for p in toSendPeers:
|
||||
if p in f.peers and f.peers[p].id != peer.id:
|
||||
sent.add(f.peers[p].send(@[RPCMsg(messages: m.messages)]))
|
||||
|
||||
# wait for all the futures now
|
||||
sent = await allFinished(sent)
|
||||
checkFutures(sent)
|
||||
|
@ -133,10 +134,13 @@ method publish*(f: FloodSub,
|
|||
for p in f.floodsub[topic]:
|
||||
trace "publishing message", name = topic, peer = p, data = data.shortLog
|
||||
sent.add(f.peers[p].send(@[RPCMsg(messages: @[msg])]))
|
||||
|
||||
# wait for all the futures now
|
||||
sent = await allFinished(sent)
|
||||
checkFutures(sent)
|
||||
|
||||
libp2p_pubsub_messages_published.inc(labelValues = [topic])
|
||||
|
||||
method unsubscribe*(f: FloodSub,
|
||||
topics: seq[TopicPair]) {.async.} =
|
||||
await procCall PubSub(f).unsubscribe(topics)
|
||||
|
|
|
@ -480,6 +480,8 @@ method publish*(g: GossipSub,
|
|||
sent.add(g.peers[p].send(@[RPCMsg(messages: @[msg])]))
|
||||
checkFutures(await allFinished(sent))
|
||||
|
||||
libp2p_pubsub_messages_published.inc(labelValues = [topic])
|
||||
|
||||
method start*(g: GossipSub) {.async.} =
|
||||
## start pubsub
|
||||
## start long running/repeating procedures
|
||||
|
|
|
@ -26,6 +26,7 @@ declareGauge(libp2p_pubsub_peers, "pubsub peer instances")
|
|||
declareGauge(libp2p_pubsub_topics, "pubsub subscribed topics")
|
||||
declareCounter(libp2p_pubsub_validation_success, "pubsub successfully validated messages")
|
||||
declareCounter(libp2p_pubsub_validation_failure, "pubsub failed validated messages")
|
||||
declarePublicCounter(libp2p_pubsub_messages_published, "published messages", labels = ["topic"])
|
||||
declareGauge(libp2p_pubsub_peers_per_topic, "pubsub peers per topic", labels = ["topic"])
|
||||
|
||||
type
|
||||
|
|
|
@ -12,6 +12,7 @@ import chronos, chronicles, metrics
|
|||
import connection,
|
||||
transports/transport,
|
||||
multistream,
|
||||
multiaddress,
|
||||
protocols/protocol,
|
||||
protocols/secure/secure,
|
||||
protocols/secure/plaintext, # for plain text
|
||||
|
|
Loading…
Reference in New Issue