From 8a184e208c85d20d3d059f32e908b1d19d784c48 Mon Sep 17 00:00:00 2001 From: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> Date: Thu, 6 Oct 2022 13:06:54 +0100 Subject: [PATCH] chore: publish nwaku version to metric (#1234) --- waku/v2/node/jsonrpc/debug_api.nim | 3 --- waku/v2/node/wakunode2.nim | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/waku/v2/node/jsonrpc/debug_api.nim b/waku/v2/node/jsonrpc/debug_api.nim index a3ae5a110..bb9071184 100644 --- a/waku/v2/node/jsonrpc/debug_api.nim +++ b/waku/v2/node/jsonrpc/debug_api.nim @@ -8,9 +8,6 @@ import logScope: topics = "debug api" -const - git_version {.strdefine.} = "n/a" - proc installDebugApiHandlers*(node: WakuNode, rpcsrv: RpcServer) = ## Debug API version 1 definitions diff --git a/waku/v2/node/wakunode2.nim b/waku/v2/node/wakunode2.nim index 106f30fb5..f2073baa2 100644 --- a/waku/v2/node/wakunode2.nim +++ b/waku/v2/node/wakunode2.nim @@ -39,6 +39,7 @@ export when defined(rln) or defined(rlnzerokit): import ../protocol/waku_rln_relay/waku_rln_relay_utils +declarePublicGauge waku_version, "Waku version info (in git describe format)", ["version"] declarePublicCounter waku_node_messages, "number of messages received", ["type"] declarePublicGauge waku_node_filters, "number of content filter subscriptions" declarePublicGauge waku_node_errors, "number of wakunode errors", ["type"] @@ -46,6 +47,9 @@ declarePublicGauge waku_node_errors, "number of wakunode errors", ["type"] logScope: topics = "wakunode" +# Git version in git describe format (defined compile time) +const git_version* {.strdefine.} = "n/a" + # Default clientId const clientId* = "Nimbus Waku v2 node" @@ -759,6 +763,8 @@ proc start*(node: WakuNode) {.async.} = ## ## Status: Implemented. + waku_version.set(1, labelValues=[git_version]) + ## NB: careful when moving this. We need to start the switch with the bind address ## BEFORE updating with announced addresses for the sake of identify. await node.switch.start() @@ -1185,7 +1191,6 @@ when isMainModule: # if called with --version, print the version and quit if conf.version: - const git_version {.strdefine.} = "n/a" echo "version / git commit hash: ", git_version quit(QuitSuccess)