From 7afea05a0dccae779f150182088d159f7a382a01 Mon Sep 17 00:00:00 2001 From: kamuikatsurgi Date: Mon, 3 Mar 2025 15:06:02 +0530 Subject: [PATCH 1/2] feat: bor_info metric --- cmd/cli/main.go | 2 ++ params/version.go | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index af4b7d8075..5863276d0b 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -4,8 +4,10 @@ import ( "os" "github.com/ethereum/go-ethereum/internal/cli" + "github.com/ethereum/go-ethereum/params" ) func main() { + params.UpdateBorInfo() os.Exit(cli.Run(os.Args[1:])) } diff --git a/params/version.go b/params/version.go index 43c57b5365..0fa58e33fd 100644 --- a/params/version.go +++ b/params/version.go @@ -18,6 +18,8 @@ package params import ( "fmt" + + "github.com/ethereum/go-ethereum/metrics" ) const ( @@ -27,7 +29,18 @@ const ( VersionMeta = "" // Version metadata to append to the version string ) -var GitCommit string +var ( + borInfo = metrics.NewRegisteredGaugeInfo("bor/info", nil) + GitCommit string +) + +// UpdateBorInfo updates the bor_info with the current git commit and version details. +func UpdateBorInfo() { + borInfo.Update(metrics.GaugeInfoValue{ + "commit": GitCommit, + "version": VersionWithMeta, + }) +} // Version holds the textual version string. var Version = func() string { From 192f6d27043557952ab498a0b3a52789139dbaed Mon Sep 17 00:00:00 2001 From: kamuikatsurgi Date: Mon, 3 Mar 2025 17:08:58 +0530 Subject: [PATCH 2/2] chore: improve comments --- params/version.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/params/version.go b/params/version.go index 0fa58e33fd..cc4add1c6f 100644 --- a/params/version.go +++ b/params/version.go @@ -30,13 +30,15 @@ const ( ) var ( - borInfo = metrics.NewRegisteredGaugeInfo("bor/info", nil) + // borInfoGauge stores Bor git commit and version details. + borInfoGauge = metrics.NewRegisteredGaugeInfo("bor/info", nil) + GitCommit string ) -// UpdateBorInfo updates the bor_info with the current git commit and version details. +// UpdateBorInfo updates the bor_info metric with the current git commit and version details. func UpdateBorInfo() { - borInfo.Update(metrics.GaugeInfoValue{ + borInfoGauge.Update(metrics.GaugeInfoValue{ "commit": GitCommit, "version": VersionWithMeta, })