deploy: bdb120d84219d0e3219e938efcace4f468694657

This commit is contained in:
rymnc 2022-10-21 09:03:47 +00:00
parent 79b6e41928
commit 3093ca8cec
7 changed files with 68 additions and 50 deletions

View File

@ -26,7 +26,7 @@ import
../../waku/v2/protocol/waku_lightpush, ../../waku/v2/protocol/waku_lightpush,
../../waku/v2/protocol/waku_filter, ../../waku/v2/protocol/waku_filter,
../../waku/v2/protocol/waku_store, ../../waku/v2/protocol/waku_store,
../../waku/v2/node/[waku_node, waku_payload], ../../waku/v2/node/[waku_node, waku_payload, waku_metrics],
../../waku/v2/node/dnsdisc/waku_dnsdisc, ../../waku/v2/node/dnsdisc/waku_dnsdisc,
../../waku/v2/node/peer_manager/peer_manager, ../../waku/v2/node/peer_manager/peer_manager,
../../waku/v2/utils/[peers, time], ../../waku/v2/utils/[peers, time],
@ -551,6 +551,14 @@ proc processInput(rfd: AsyncFD) {.async.} =
echo "your rln identity key is: ", node.wakuRlnRelay.membershipKeyPair.idKey.inHex() echo "your rln identity key is: ", node.wakuRlnRelay.membershipKeyPair.idKey.inHex()
echo "your rln identity commitment key is: ", node.wakuRlnRelay.membershipKeyPair.idCommitment.inHex() echo "your rln identity commitment key is: ", node.wakuRlnRelay.membershipKeyPair.idCommitment.inHex()
if conf.metricsLogging:
startMetricsLog()
if conf.metricsServer:
startMetricsServer(conf.metricsServerAddress,
Port(conf.metricsServerPort + conf.portsShift))
await chat.readWriteLoop() await chat.readWriteLoop()
if conf.keepAlive: if conf.keepAlive:

View File

@ -180,7 +180,7 @@ type
metricsLogging* {. metricsLogging* {.
desc: "Enable metrics logging: true|false" desc: "Enable metrics logging: true|false"
defaultValue: false defaultValue: true
name: "metrics-logging" }: bool name: "metrics-logging" }: bool
## DNS discovery config ## DNS discovery config

View File

@ -31,13 +31,10 @@ import
../../waku/v2/node/storage/message/sqlite_store, ../../waku/v2/node/storage/message/sqlite_store,
../../waku/v2/node/storage/message/message_retention_policy_capacity, ../../waku/v2/node/storage/message/message_retention_policy_capacity,
../../waku/v2/node/storage/message/message_retention_policy_time, ../../waku/v2/node/storage/message/message_retention_policy_time,
../../waku/v2/node/wakuswitch, ../../waku/v2/node/[wakuswitch, waku_node, waku_metrics],
../../waku/v2/node/waku_node, ../../waku/v2/utils/[peers, wakuenr],
../../waku/v2/utils/peers,
../../waku/v2/utils/wakuenr,
../../waku/common/utils/nat, ../../waku/common/utils/nat,
./wakunode2_setup_rest, ./wakunode2_setup_rest,
./wakunode2_setup_metrics,
./wakunode2_setup_rpc, ./wakunode2_setup_rpc,
./wakunode2_setup_sql_migrations, ./wakunode2_setup_sql_migrations,
./config ./config

View File

@ -2,7 +2,7 @@
# libtool - Provide generalized library-building support services. # libtool - Provide generalized library-building support services.
# Generated automatically by config.status (libbacktrace) version-unused # Generated automatically by config.status (libbacktrace) version-unused
# Libtool was configured on host fv-az39-868: # Libtool was configured on host fv-az163-754:
# NOTE: Changes made to this file will be lost: look at ltmain.sh. # NOTE: Changes made to this file will be lost: look at ltmain.sh.
# #
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,

View File

@ -8,22 +8,22 @@ import
metrics, metrics,
metrics/chronos_httpserver metrics/chronos_httpserver
import import
../../waku/v2/protocol/waku_filter, ../protocol/waku_filter,
../../waku/v2/protocol/waku_store/protocol_metrics, ../protocol/waku_store/protocol_metrics,
../../waku/v2/protocol/waku_lightpush, ../protocol/waku_lightpush,
../../waku/v2/protocol/waku_swap/waku_swap, ../protocol/waku_swap/waku_swap,
../../waku/v2/protocol/waku_peer_exchange, ../protocol/waku_peer_exchange,
../../waku/v2/utils/collector, ../utils/collector,
../../waku/v2/node/peer_manager/peer_manager, ./peer_manager/peer_manager,
../../waku/v2/node/waku_node, ./waku_node
./config
when defined(rln) or defined(rlnzerokit): when defined(rln) or defined(rlnzerokit):
import ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_metrics import ../protocol/waku_rln_relay/waku_rln_relay_metrics
const LogInterval = 30.seconds
logScope: logScope:
topics = "wakunode.setup.metrics" topics = "waku.metrics"
proc startMetricsServer*(serverIp: ValidIpAddress, serverPort: Port) = proc startMetricsServer*(serverIp: ValidIpAddress, serverPort: Port) =
@ -36,11 +36,12 @@ proc startMetricsServer*(serverIp: ValidIpAddress, serverPort: Port) =
info "Metrics HTTP server started", serverIp, serverPort info "Metrics HTTP server started", serverIp, serverPort
type
# https://github.com/nim-lang/Nim/issues/17369
MetricsLogger = proc(udata: pointer) {.gcsafe, raises: [Defect].}
proc startMetricsLog*() = proc startMetricsLog*() =
# https://github.com/nim-lang/Nim/issues/17369 var logMetrics: MetricsLogger
var logMetrics: proc(udata: pointer) {.gcsafe, raises: [Defect].}
var cumulativeErrors = 0.float64 var cumulativeErrors = 0.float64
var cumulativeConns = 0.float64 var cumulativeConns = 0.float64
@ -56,23 +57,21 @@ proc startMetricsLog*() =
# track cumulative values # track cumulative values
let freshErrorCount = parseAndAccumulate(waku_node_errors, cumulativeErrors) let freshErrorCount = parseAndAccumulate(waku_node_errors, cumulativeErrors)
let freshConnCount = parseAndAccumulate(waku_node_conns_initiated, cumulativeConns) let freshConnCount = parseAndAccumulate(waku_node_conns_initiated, cumulativeConns)
info "Total connections initiated", count = freshConnCount info "Total connections initiated", count = freshConnCount
info "Total messages", count = parseCollectorIntoF64(waku_node_messages) info "Total messages", count = collectorAsF64(waku_node_messages)
info "Total swap peers", count = parseCollectorIntoF64(waku_swap_peers_count) info "Total swap peers", count = collectorAsF64(waku_swap_peers_count)
info "Total filter peers", count = parseCollectorIntoF64(waku_filter_peers) info "Total filter peers", count = collectorAsF64(waku_filter_peers)
info "Total store peers", count = parseCollectorIntoF64(waku_store_peers) info "Total store peers", count = collectorAsF64(waku_store_peers)
info "Total lightpush peers", count = parseCollectorIntoF64(waku_lightpush_peers) info "Total lightpush peers", count = collectorAsF64(waku_lightpush_peers)
info "Total peer exchange peers", count = parseCollectorIntoF64(waku_px_peers) info "Total peer exchange peers", count = collectorAsF64(waku_px_peers)
info "Total errors", count = freshErrorCount info "Total errors", count = freshErrorCount
info "Total active filter subscriptions", count = parseCollectorIntoF64(waku_filter_subscribers) info "Total active filter subscriptions", count = collectorAsF64(waku_filter_subscribers)
# Start protocol specific metrics logging # Start protocol specific metrics logging
when defined(rln) or defined(rlnzerokit): when defined(rln) or defined(rlnzerokit):
logRlnMetrics() logRlnMetrics()
discard setTimer(Moment.fromNow(30.seconds), logMetrics) discard setTimer(Moment.fromNow(LogInterval), logMetrics)
discard setTimer(Moment.fromNow(30.seconds), logMetrics)
discard setTimer(Moment.fromNow(LogInterval), logMetrics)

View File

@ -41,8 +41,11 @@ declarePublicGauge(waku_rln_instance_creation_duration_seconds, "time taken to c
declarePublicGauge(waku_rln_membership_insertion_duration_seconds, "time taken to insert a new member into the local merkle tree") declarePublicGauge(waku_rln_membership_insertion_duration_seconds, "time taken to insert a new member into the local merkle tree")
declarePublicGauge(waku_rln_membership_credentials_import_duration_seconds, "time taken to import membership credentials") declarePublicGauge(waku_rln_membership_credentials_import_duration_seconds, "time taken to import membership credentials")
proc getRlnMetricsLogger*(): proc() = type
var logMetrics: proc() {.gcsafe, raises: [Defect].} RLNMetricsLogger = proc() {.gcsafe, raises: [Defect].}
proc getRlnMetricsLogger*(): RLNMetricsLogger =
var logMetrics: RLNMetricsLogger
var cumulativeErrors = 0.float64 var cumulativeErrors = 0.float64
var cumulativeMessages = 0.float64 var cumulativeMessages = 0.float64

View File

@ -1,19 +1,30 @@
import {.push raises: [Defect].}
metrics
proc parseCollectorIntoF64*(collector: Collector): float64 = import
var total = 0.float64 metrics
for key in collector.metrics.keys():
try: proc parseCollectorIntoF64(collector: Collector): float64 {.gcsafe, raises: [Defect] } =
total = total + collector.value(key) {.gcsafe.}:
except KeyError: var total = 0.float64
discard for key in collector.metrics.keys():
return total try:
total = total + collector.value(key)
except KeyError:
discard
return total
template parseAndAccumulate*(collector: Collector, cumulativeValue: float64): float64 = template parseAndAccumulate*(collector: Collector, cumulativeValue: float64): float64 =
## This template is used to get metrics in a window ## This template is used to get metrics in a window
## according to a cumulative value passed in ## according to a cumulative value passed in
let total = parseCollectorIntoF64(collector) {.gcsafe.}:
let freshCount = total - cumulativeValue let total = parseCollectorIntoF64(collector)
cumulativeValue = total let freshCount = total - cumulativeValue
freshCount cumulativeValue = total
freshCount
template collectorAsF64*(collector: Collector): float64 =
## This template is used to get metrics from 0
## Serves as a wrapper for parseCollectorIntoF64 which is gcsafe
{.gcsafe.}:
let total = parseCollectorIntoF64(collector)
total