From 1b8a7d271359418d6fe72bbe2976b66ab370df9b Mon Sep 17 00:00:00 2001 From: Tanguy Date: Wed, 6 Sep 2023 18:05:59 +0200 Subject: [PATCH] IDontWant metrics (#946) --- libp2p/protocols/pubsub/gossipsub.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libp2p/protocols/pubsub/gossipsub.nim b/libp2p/protocols/pubsub/gossipsub.nim index ef4cbafea..93fcfda1c 100644 --- a/libp2p/protocols/pubsub/gossipsub.nim +++ b/libp2p/protocols/pubsub/gossipsub.nim @@ -40,6 +40,8 @@ logScope: declareCounter(libp2p_gossipsub_failed_publish, "number of failed publish") declareCounter(libp2p_gossipsub_invalid_topic_subscription, "number of invalid topic subscriptions that happened") declareCounter(libp2p_gossipsub_duplicate_during_validation, "number of duplicates received during message validation") +declareCounter(libp2p_gossipsub_idontwant_saved_messages, "number of duplicates avoided by idontwant") +declareCounter(libp2p_gossipsub_saved_bytes, "bytes saved by gossipsub optimizations", labels=["kind"]) declareCounter(libp2p_gossipsub_duplicate, "number of duplicates received") declareCounter(libp2p_gossipsub_received, "number of messages received (deduplicated)") @@ -307,6 +309,7 @@ proc validateAndRelay(g: GossipSub, var seenPeers: HashSet[PubSubPeer] discard g.validationSeen.pop(msgIdSalted, seenPeers) libp2p_gossipsub_duplicate_during_validation.inc(seenPeers.len.int64) + libp2p_gossipsub_saved_bytes.inc((msg.data.len * seenPeers.len).int64, labelValues = ["validation_duplicate"]) case validation of ValidationResult.Reject: @@ -350,6 +353,8 @@ proc validateAndRelay(g: GossipSub, for heDontWant in peer.heDontWants: if msgId in heDontWant: seenPeers.incl(peer) + libp2p_gossipsub_idontwant_saved_messages.inc + libp2p_gossipsub_saved_bytes.inc(msg.data.len.int64, labelValues = ["idontwant"]) break toSendPeers.excl(seenPeers)