From 0d0ef3519fa5fe0bd13ecd42b95f9a513d8311c9 Mon Sep 17 00:00:00 2001 From: Diego Date: Wed, 31 Jan 2024 23:59:05 +0100 Subject: [PATCH] add metric --- libp2p/protocols/pubsub/pubsubpeer.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libp2p/protocols/pubsub/pubsubpeer.nim b/libp2p/protocols/pubsub/pubsubpeer.nim index c2f23b2d9..40996ca3e 100644 --- a/libp2p/protocols/pubsub/pubsubpeer.nim +++ b/libp2p/protocols/pubsub/pubsubpeer.nim @@ -34,6 +34,9 @@ when defined(libp2p_expensive_metrics): declareGauge(libp2p_gossipsub_priority_queue_size, "the number of messages in the priority queue", labels = ["id"]) declareGauge(libp2p_gossipsub_non_priority_queue_size, "the number of messages in the non-priority queue", labels = ["id"]) + declareCounter(libp2p_gossipsub_non_priority_msgs_dropped, "the number of dropped messages in the non-priority queue", labels = ["id"]) + + type PeerRateLimitError* = object of CatchableError @@ -393,6 +396,8 @@ proc sendNonPriorityTask(p: PubSubPeer) {.async.} = when defined(libp2p_expensive_metrics): libp2p_gossipsub_non_priority_queue_size.dec(labelValues = [$p.peerId]) if Moment.now() - ttlMsg.ttl >= p.rpcmessagequeue.maxDurationInNonPriorityQueue: + when defined(libp2p_expensive_metrics): + libp2p_gossipsub_non_priority_msgs_dropped.inc(labelValues = [$p.peerId]) continue await p.sendMsg(ttlMsg.msg)