Add prysm version to prometheus (#8527)

* Add prysm version to prometheus

* gofmt

* apply suggestion

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
Eduard Klementiev 2021-03-01 20:50:20 +03:00 committed by GitHub
parent f973924fbf
commit a3781e2ffc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -2,7 +2,10 @@ load("@prysm//tools/go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["version.go"],
srcs = [
"metrics.go",
"version.go",
],
importpath = "github.com/prysmaticlabs/prysm/shared/version",
visibility = ["//visibility:public"],
x_defs = {
@ -10,4 +13,8 @@ go_library(
"buildDate": "{DATE}",
"gitTag": "{STABLE_GIT_TAG}",
},
deps = [
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
],
)

15
shared/version/metrics.go Normal file
View File

@ -0,0 +1,15 @@
package version
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var prysmInfo = promauto.NewGauge(prometheus.GaugeOpts{
Name: "prysm_version",
ConstLabels: prometheus.Labels{"version": gitTag, "commit": gitCommit},
})
func init() {
prysmInfo.Set(float64(1))
}