2023-04-05 14:14:42 +00:00
|
|
|
# Nimbus fluffy
|
2024-02-28 17:31:45 +00:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-04-05 14:14:42 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
|
|
|
{.push raises: [].}
|
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
import std/strutils, stew/byteutils, metrics
|
2023-04-05 14:14:42 +00:00
|
|
|
|
|
|
|
const
|
|
|
|
versionMajor* = 0
|
|
|
|
versionMinor* = 1
|
|
|
|
versionBuild* = 0
|
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
gitRevision* = strip(staticExec("git rev-parse --short HEAD"))[0 .. 5]
|
2023-04-05 14:14:42 +00:00
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
versionAsStr* = $versionMajor & "." & $versionMinor & "." & $versionBuild
|
2023-04-05 14:14:42 +00:00
|
|
|
|
|
|
|
fullVersionStr* = "v" & versionAsStr & "-" & gitRevision
|
|
|
|
|
|
|
|
clientName* = "fluffy"
|
|
|
|
|
2023-09-07 14:27:13 +00:00
|
|
|
nimFullBanner = staticExec("nim --version")
|
|
|
|
nimBanner* = staticExec("nim --version | grep Version")
|
2023-04-05 14:14:42 +00:00
|
|
|
|
|
|
|
# The web3_clientVersion
|
2024-02-28 17:31:45 +00:00
|
|
|
clientVersion* =
|
|
|
|
clientName & "/" & fullVersionStr & "/" & hostOS & "-" & hostCPU & "/" & "Nim" &
|
|
|
|
NimVersion
|
2023-09-07 14:27:13 +00:00
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
compileYear = CompileDate[0 ..< 4] # YYYY-MM-DD (UTC)
|
2023-09-07 14:27:13 +00:00
|
|
|
copyrightBanner* =
|
|
|
|
"Copyright (c) 2021-" & compileYear & " Status Research & Development GmbH"
|
|
|
|
|
2023-09-20 10:19:40 +00:00
|
|
|
# Short debugging identifier to be placed in the ENR
|
|
|
|
enrClientInfoShort* = toBytes("f")
|
|
|
|
|
2023-09-07 14:27:13 +00:00
|
|
|
func getNimGitHash*(): string =
|
|
|
|
const gitPrefix = "git hash: "
|
|
|
|
let tmp = splitLines(nimFullBanner)
|
|
|
|
if tmp.len == 0:
|
|
|
|
return
|
|
|
|
for line in tmp:
|
|
|
|
if line.startsWith(gitPrefix) and line.len > 8 + gitPrefix.len:
|
2024-02-28 17:31:45 +00:00
|
|
|
result = line[gitPrefix.len ..< gitPrefix.len + 8]
|
2023-09-07 14:27:13 +00:00
|
|
|
|
|
|
|
# TODO: Currently prefixing these metric names as the non prefixed names give
|
|
|
|
# a collector already registered conflict at runtime. This is due to the same
|
|
|
|
# names in nimbus-eth2 nimbus_binary_common.nim even though there are no direct
|
|
|
|
# imports of that file.
|
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
declareGauge versionGauge,
|
|
|
|
"Fluffy version info (as metric labels)",
|
|
|
|
["version", "commit"],
|
|
|
|
name = "fluffy_version"
|
2023-09-07 14:27:13 +00:00
|
|
|
versionGauge.set(1, labelValues = [fullVersionStr, gitRevision])
|
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
declareGauge nimVersionGauge,
|
|
|
|
"Nim version info", ["version", "nim_commit"], name = "fluffy_nim_version"
|
2023-09-07 14:27:13 +00:00
|
|
|
nimVersionGauge.set(1, labelValues = [NimVersion, getNimGitHash()])
|