nwaku/waku/node/waku_metrics.nim
Alvaro Revuelta e861317209
chore: remove deprecated legacy filter protocol (#2507)
* chore: remove deprecated legacy filter protocol

* fix: do not use legacy import in test

* fix: remove legacy test references

* fix: more test fixes, starting filter client

* fix: sigh. more references to remove.

* fix: fix dereferencing error

* fix: fix merge mess up

* fix: sigh. merge tool used tabs.

* fix: more peer manager tests needed fixing

---------

Co-authored-by: Hanno Cornelius <hanno@status.im>
Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com>
2024-03-25 18:07:56 +00:00

57 lines
1.8 KiB
Nim

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronicles, chronos, metrics, metrics/chronos_httpserver
import
../waku_rln_relay/protocol_metrics as rln_metrics,
../utils/collector,
./peer_manager,
./waku_node
const LogInterval = 10.minutes
logScope:
topics = "waku node metrics"
proc startMetricsLog*() =
var logMetrics: CallbackFunc
var cumulativeErrors = 0.float64
var cumulativeConns = 0.float64
let logRlnMetrics = getRlnMetricsLogger()
logMetrics = CallbackFunc(
proc(udata: pointer) {.gcsafe.} =
# TODO: libp2p_pubsub_peers is not public, so we need to make this either
# public in libp2p or do our own peer counting after all.
# track cumulative values
let freshErrorCount = parseAndAccumulate(waku_node_errors, cumulativeErrors)
let freshConnCount =
parseAndAccumulate(waku_node_conns_initiated, cumulativeConns)
let totalMessages = collectorAsF64(waku_node_messages)
let storePeers = collectorAsF64(waku_store_peers)
let pxPeers = collectorAsF64(waku_px_peers)
let lightpushPeers = collectorAsF64(waku_lightpush_peers)
let filterPeers = collectorAsF64(waku_filter_peers)
info "Total connections initiated", count = $freshConnCount
info "Total messages", count = totalMessages
info "Total store peers", count = storePeers
info "Total peer exchange peers", count = pxPeers
info "Total lightpush peers", count = lightpushPeers
info "Total filter peers", count = filterPeers
info "Total errors", count = $freshErrorCount
# Start protocol specific metrics logging
logRlnMetrics()
discard setTimer(Moment.fromNow(LogInterval), logMetrics)
)
discard setTimer(Moment.fromNow(LogInterval), logMetrics)