Skip to content

Commit 5594bcb

Browse files
fix: more metrics issues when libp2p_expensive_metrics is enabled (#1016)
1 parent d46bcdb commit 5594bcb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

libp2p/protocols/pubsub/gossipsub.nim

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ declareCounter(libp2p_gossipsub_saved_bytes, "bytes saved by gossipsub optimizat
4646
declareCounter(libp2p_gossipsub_duplicate, "number of duplicates received")
4747
declareCounter(libp2p_gossipsub_received, "number of messages received (deduplicated)")
4848

49+
when defined(libp2p_expensive_metrics):
50+
declareCounter(libp2p_pubsub_received_messages, "number of messages received", labels = ["id", "topic"])
51+
4952
proc init*(_: type[GossipSubParams]): GossipSubParams =
5053
GossipSubParams(
5154
explicit: true,
@@ -428,7 +431,7 @@ method rpcHandler*(g: GossipSub,
428431

429432
when defined(libp2p_expensive_metrics):
430433
for m in rpcMsg.messages:
431-
for t in m.topicIDs:
434+
for t in m.topicIds:
432435
libp2p_pubsub_received_messages.inc(labelValues = [$peer.peerId, t])
433436

434437
trace "decoded msg from peer", peer, msg = rpcMsg.shortLog

libp2p/protocols/pubsub/pubsubpeer.nim

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ logScope:
2828

2929
when defined(libp2p_expensive_metrics):
3030
declareCounter(libp2p_pubsub_sent_messages, "number of messages sent", labels = ["id", "topic"])
31-
declareCounter(libp2p_pubsub_received_messages, "number of messages received", labels = ["id", "topic"])
3231
declareCounter(libp2p_pubsub_skipped_received_messages, "number of received skipped messages", labels = ["id"])
3332
declareCounter(libp2p_pubsub_skipped_sent_messages, "number of sent skipped messages", labels = ["id"])
3433

@@ -224,7 +223,7 @@ proc hasSendConn*(p: PubSubPeer): bool =
224223
template sendMetrics(msg: RPCMsg): untyped =
225224
when defined(libp2p_expensive_metrics):
226225
for x in msg.messages:
227-
for t in x.topicIDs:
226+
for t in x.topicIds:
228227
# metrics
229228
libp2p_pubsub_sent_messages.inc(labelValues = [$p.peerId, t])
230229

0 commit comments

Comments
 (0)