Skip to content

Commit

Permalink
add metric
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Jan 31, 2024
1 parent 61a1300 commit 5006b79
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libp2p/protocols/pubsub/pubsubpeer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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

Expand Down Expand Up @@ -383,6 +386,7 @@ 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:
libp2p_gossipsub_non_priority_msgs_dropped.inc(labelValues = [$p.peerId])
continue
await p.sendMsg(ttlMsg.msg)

Expand Down

0 comments on commit 5006b79

Please sign in to comment.