mirror of
https://github.com/netbirdio/dex.git
synced 2026-05-22 18:43:53 -07:00
new Prometheus metrics build_info (#3558)
Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
This commit is contained in:
@@ -50,6 +50,15 @@ type serveOptions struct {
|
||||
grpcAddr string
|
||||
}
|
||||
|
||||
var buildInfo = prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "build_info",
|
||||
Namespace: "dex",
|
||||
Help: "A metric with a constant '1' value labeled by version from which Dex was built.",
|
||||
},
|
||||
[]string{"version", "go_version", "platform"},
|
||||
)
|
||||
|
||||
func commandServe() *cobra.Command {
|
||||
options := serveOptions{}
|
||||
|
||||
@@ -117,6 +126,10 @@ func runServe(options serveOptions) error {
|
||||
logger.Info("config issuer", "issuer", c.Issuer)
|
||||
|
||||
prometheusRegistry := prometheus.NewRegistry()
|
||||
|
||||
prometheusRegistry.MustRegister(buildInfo)
|
||||
recordBuildInfo()
|
||||
|
||||
err = prometheusRegistry.Register(collectors.NewGoCollector())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to register Go runtime metrics: %v", err)
|
||||
@@ -684,3 +697,8 @@ func loadTLSConfig(certFile, keyFile, caFile string, baseConfig *tls.Config) (*t
|
||||
}
|
||||
return loadedConfig, nil
|
||||
}
|
||||
|
||||
// recordBuildInfo publishes information about Dex version and runtime info through an info metric (gauge).
|
||||
func recordBuildInfo() {
|
||||
buildInfo.WithLabelValues(version, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)).Set(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user