Skip to content

Commit

Permalink
Add prysm version to prometheus (#8527)
Browse files Browse the repository at this point in the history
* Add prysm version to prometheus

* gofmt

* apply suggestion

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
  • Loading branch information
eklm and rauljordan committed Mar 1, 2021
1 parent f973924 commit a3781e2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion shared/version/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ 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 = {
"gitCommit": "{STABLE_GIT_COMMIT}",
"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 changes: 15 additions & 0 deletions shared/version/metrics.go
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit a3781e2

Please sign in to comment.