add nim commit to the gauge (#4155)

This commit is contained in:
Miran 2022-09-20 17:52:24 +02:00 committed by GitHub
parent 154723947b
commit fcc46d3e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -116,8 +116,8 @@ declareGauge next_action_wait,
declareGauge versionGauge, "Nimbus version info (as metric labels)", ["version", "commit"], name = "version"
versionGauge.set(1, labelValues=[fullVersionStr, gitRevision])
declareGauge nimVersionGauge, "Nim version info", ["nim_version"], name = "Nim_version"
nimVersionGauge.set(1, labelValues=[NimVersion])
declareGauge nimVersionGauge, "Nim version info", ["version", "nim_commit"], name = "nim_version"
nimVersionGauge.set(1, labelValues=[NimVersion, getNimGitHash()])
logScope: topics = "beacnde"

View File

@ -24,6 +24,7 @@ const
gitRevision* = strip(staticExec("git rev-parse --short HEAD"))[0..5]
nimFullBanner* = staticExec("nim --version")
nimBanner* = staticExec("nim --version | grep Version")
versionAsStr* =
@ -31,16 +32,18 @@ const
fullVersionStr* = "v" & versionAsStr & "-" & gitRevision & "-" & versionBlob
func shortNimBanner*(): string =
func getNimGitHash*(): string =
const gitPrefix = "git hash: "
let tmp = splitLines(nimBanner)
let tmp = splitLines(nimFullBanner)
if tmp.len == 0:
return
var gitHash = ""
for line in tmp:
if line.startsWith(gitPrefix) and line.len > 8 + gitPrefix.len:
gitHash = line[gitPrefix.len..<gitPrefix.len + 8]
result = line[gitPrefix.len..<gitPrefix.len + 8]
func shortNimBanner*(): string =
let gitHash = getNimGitHash()
let tmp = splitLines(nimFullBanner)
if gitHash.len > 0:
tmp[0] & " (" & gitHash & ")"
else: