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,