From 809df8d04d660d50a7134c7e3911a5a63e1a58dd Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni Date: Thu, 26 Nov 2020 16:20:34 +0900 Subject: [PATCH] add some extra gossip metrics --- libp2p/protocols/pubsub/gossipsub.nim | 4 ++++ libp2p/protocols/pubsub/pubsub.nim | 3 +++ 2 files changed, 7 insertions(+) diff --git a/libp2p/protocols/pubsub/gossipsub.nim b/libp2p/protocols/pubsub/gossipsub.nim index 5c4f2ae..739ef4c 100644 --- a/libp2p/protocols/pubsub/gossipsub.nim +++ b/libp2p/protocols/pubsub/gossipsub.nim @@ -1167,6 +1167,7 @@ method rpcHandler*(g: GossipSub, # also have to be careful to only include validated messages g.broadcast(toSeq(toSendPeers), RPCMsg(messages: @[msg])) trace "forwared message to peers", peers = toSendPeers.len, msgId, peer + libp2p_pubsub_messages_rebroadcasted.inc() if rpcMsg.control.isSome: let control = rpcMsg.control.get() @@ -1302,6 +1303,9 @@ method publish*(g: GossipSub, when defined(libp2p_expensive_metrics): if peers.len > 0: libp2p_pubsub_messages_published.inc(labelValues = [topic]) + else: + if peers.len > 0: + libp2p_pubsub_messages_published.inc() trace "Published message to peers" diff --git a/libp2p/protocols/pubsub/pubsub.nim b/libp2p/protocols/pubsub/pubsub.nim index 9dd1c7f..ae9bc34 100644 --- a/libp2p/protocols/pubsub/pubsub.nim +++ b/libp2p/protocols/pubsub/pubsub.nim @@ -36,6 +36,9 @@ declareCounter(libp2p_pubsub_validation_failure, "pubsub failed validated messag declareCounter(libp2p_pubsub_validation_ignore, "pubsub ignore validated messages") when defined(libp2p_expensive_metrics): declarePublicCounter(libp2p_pubsub_messages_published, "published messages", labels = ["topic"]) +else: + declarePublicCounter(libp2p_pubsub_messages_published, "published messages") +declarePublicCounter(libp2p_pubsub_messages_rebroadcasted, "re-broadcasted messages") type TopicHandler* = proc(topic: string,