mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-14 17:04:53 +00:00
deploy: ed53bcdec6c8e1eecd5da9991ebc37def00cb090
This commit is contained in:
parent
1cfb1720b4
commit
24ef6196c5
@ -2,7 +2,7 @@
|
||||
|
||||
# libtool - Provide generalized library-building support services.
|
||||
# Generated automatically by config.status (libbacktrace) version-unused
|
||||
# Libtool was configured on host fv-az105-780:
|
||||
# Libtool was configured on host fv-az198-353:
|
||||
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
||||
#
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
||||
|
@ -324,7 +324,7 @@ type
|
||||
|
||||
metricsLogging* {.
|
||||
desc: "Enable metrics logging: true|false"
|
||||
defaultValue: false
|
||||
defaultValue: true
|
||||
name: "metrics-logging" }: bool
|
||||
|
||||
## DNS discovery config
|
||||
|
@ -8,7 +8,10 @@ import
|
||||
metrics,
|
||||
metrics/chronos_httpserver,
|
||||
./config,
|
||||
./wakunode2
|
||||
./wakunode2,
|
||||
../protocol/waku_filter,
|
||||
../protocol/waku_store,
|
||||
../protocol/waku_lightpush
|
||||
|
||||
logScope:
|
||||
topics = "wakunode.setup.metrics"
|
||||
@ -24,24 +27,46 @@ proc startMetricsServer*(serverIp: ValidIpAddress, serverPort: Port) =
|
||||
|
||||
info "Metrics HTTP server started", serverIp, serverPort
|
||||
|
||||
proc parseCollectorIntoF64(collector: Collector): float64 =
|
||||
var total = 0.float64
|
||||
for key in collector.metrics.keys():
|
||||
try:
|
||||
total = total + collector.value(key)
|
||||
except KeyError:
|
||||
discard
|
||||
return total
|
||||
|
||||
proc startMetricsLog*() =
|
||||
# https://github.com/nim-lang/Nim/issues/17369
|
||||
var logMetrics: proc(udata: pointer) {.gcsafe, raises: [Defect].}
|
||||
|
||||
var cumulativeErrors = 0.float64
|
||||
var cumulativeConns = 0.float64
|
||||
|
||||
logMetrics = 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.
|
||||
var totalMessages = 0.float64
|
||||
for key in waku_node_messages.metrics.keys():
|
||||
try:
|
||||
totalMessages = totalMessages + waku_node_messages.value(key)
|
||||
except KeyError:
|
||||
discard
|
||||
|
||||
info "Node metrics", totalMessages
|
||||
discard setTimer(Moment.fromNow(2.seconds), logMetrics)
|
||||
let totalErrors = parseCollectorIntoF64(waku_node_errors)
|
||||
let totalConnections = parseCollectorIntoF64(waku_node_conns_initiated)
|
||||
|
||||
# track cumulative, and then max.
|
||||
let freshErrorCount = max(totalErrors - cumulativeErrors, 0)
|
||||
let freshConnCount = max(totalConnections - cumulativeConns, 0)
|
||||
|
||||
cumulativeErrors = totalErrors
|
||||
cumulativeConns = totalConnections
|
||||
info "Total connections initiated", count = freshConnCount
|
||||
info "Total messages", count = parseCollectorIntoF64(waku_node_messages)
|
||||
info "Total swap peers", count = parseCollectorIntoF64(waku_swap_peers_count)
|
||||
info "Total filter peers", count = parseCollectorIntoF64(waku_filter_peers)
|
||||
info "Total store peers", count = parseCollectorIntoF64(waku_store_peers)
|
||||
info "Total lightpush peers", count = parseCollectorIntoF64(waku_lightpush_peers)
|
||||
info "Total errors", count = freshErrorCount
|
||||
info "Total active filter subscriptions", count = parseCollectorIntoF64(waku_filter_subscribers)
|
||||
|
||||
discard setTimer(Moment.fromNow(30.seconds), logMetrics)
|
||||
|
||||
discard setTimer(Moment.fromNow(2.seconds), logMetrics)
|
||||
discard setTimer(Moment.fromNow(30.seconds), logMetrics)
|
||||
|
Loading…
x
Reference in New Issue
Block a user