add some extra gossip metrics

This commit is contained in:
Giovanni Petrantoni 2020-11-26 16:20:34 +09:00
parent 6c7f2766fe
commit 809df8d04d
2 changed files with 7 additions and 0 deletions

View File

@ -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"

View File

@ -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,