nim-libp2p icon indicating copy to clipboard operation
nim-libp2p copied to clipboard

simplify per-topic metric collection

Open cskiraly opened this issue 2 years ago • 2 comments

removing some of the repeated metrics code for per-topic metrics in PubSub and co.

cskiraly avatar Mar 17 '22 10:03 cskiraly

Discussion on discord: Tanguy — Today at 1:01 PM My only issue with the current technique is that it only works for inc (and to be fair, that's all we have right now)

Maybe have a proc metricTopicLabel(p: PubSub, t: string): string = p.knownTopics.containsOr(topic, "generic")

and then libp2p_pubsub_broadcast_subscriptions.inc(npeers, labelValues = p.metricTopicLabel(topic)) ? cskiraly — Today at 2:15 PM sounds like a good compromise. Tanguy — Today at 2:18 PM Btw, we could also remove the knownTopics from PubSub completely, it's just a copy from a constant in pubsub.nim That may simplify the code a little bit (don't need the PubSub in metricTopicLabel)

Menduist avatar Mar 17 '22 17:03 Menduist

very nice, much needed cleanup.

dryajov avatar Apr 06 '22 23:04 dryajov