Skip to content

Commit

Permalink
fix: more metrics issues when libp2p_expensive_metrics is enabled (#1016
Browse files Browse the repository at this point in the history
)
  • Loading branch information
diegomrsantos authored Jan 30, 2024
1 parent d46bcdb commit 5594bcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion libp2p/protocols/pubsub/gossipsub.nim
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ declareCounter(libp2p_gossipsub_saved_bytes, "bytes saved by gossipsub optimizat
declareCounter(libp2p_gossipsub_duplicate, "number of duplicates received")
declareCounter(libp2p_gossipsub_received, "number of messages received (deduplicated)")

when defined(libp2p_expensive_metrics):
declareCounter(libp2p_pubsub_received_messages, "number of messages received", labels = ["id", "topic"])

proc init*(_: type[GossipSubParams]): GossipSubParams =
GossipSubParams(
explicit: true,
Expand Down Expand Up @@ -428,7 +431,7 @@ method rpcHandler*(g: GossipSub,

when defined(libp2p_expensive_metrics):
for m in rpcMsg.messages:
for t in m.topicIDs:
for t in m.topicIds:
libp2p_pubsub_received_messages.inc(labelValues = [$peer.peerId, t])

trace "decoded msg from peer", peer, msg = rpcMsg.shortLog
Expand Down
3 changes: 1 addition & 2 deletions libp2p/protocols/pubsub/pubsubpeer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ logScope:

when defined(libp2p_expensive_metrics):
declareCounter(libp2p_pubsub_sent_messages, "number of messages sent", labels = ["id", "topic"])
declareCounter(libp2p_pubsub_received_messages, "number of messages received", labels = ["id", "topic"])
declareCounter(libp2p_pubsub_skipped_received_messages, "number of received skipped messages", labels = ["id"])
declareCounter(libp2p_pubsub_skipped_sent_messages, "number of sent skipped messages", labels = ["id"])

Expand Down Expand Up @@ -224,7 +223,7 @@ proc hasSendConn*(p: PubSubPeer): bool =
template sendMetrics(msg: RPCMsg): untyped =
when defined(libp2p_expensive_metrics):
for x in msg.messages:
for t in x.topicIDs:
for t in x.topicIds:
# metrics
libp2p_pubsub_sent_messages.inc(labelValues = [$p.peerId, t])

Expand Down

0 comments on commit 5594bcb

Please sign in to comment.