nim-libp2p
nim-libp2p copied to clipboard
simplify per-topic metric collection
removing some of the repeated metrics code for per-topic metrics in PubSub and co.
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)
very nice, much needed cleanup.