add build information to metrics

Signed-off-by: David Christofas <dchristofas@owncloud.com>
This commit is contained in:
David Christofas committed 2020-09-25 13:15:20 +02:00
1 parent ff8fc23ce5
commit dab58c3637
6 files changed
+22 -1

No files matched your search

@@ -0,0 +1,5 @@
Enhancement: add build information to the metrics
Added a new field to the metrics to show build information like the version.
https://github.com/owncloud/product/issues/226
+1
View File
@@ -32,6 +32,7 @@ func Execute() error {
Flags: flagset.RootWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Version = version.String
return ParseConfig(c, cfg)
},
+4 -1
View File
@@ -2,6 +2,7 @@ package command
import (
"context"
"github.com/owncloud/ocis/glauth/pkg/metrics"
"os"
"os/signal"
"strings"
@@ -134,11 +135,13 @@ func Server(cfg *config.Config) *cli.Command {
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
metrics = metrics.New()
)
defer cancel()
metrics.BuildInfo.WithLabelValues(cfg.Version).Set(1)
{
cfg := glauthcfg.Config{
LDAP: glauthcfg.LDAP{
+1
View File
@@ -66,6 +66,7 @@ type Config struct {
Ldap Ldap
Ldaps Ldaps
Backend Backend
Version string
}
// New initializes a new configuration with or without defaults.
+9
View File
@@ -1,5 +1,7 @@
package metrics
import "github.com/prometheus/client_golang/prometheus"
var (
// Namespace defines the namespace for the defines metrics.
Namespace = "ocis"
@@ -11,6 +13,7 @@ var (
// Metrics defines the available metrics of this service.
type Metrics struct {
// Counter *prometheus.CounterVec
BuildInfo *prometheus.GaugeVec
}
// New initializes the available metrics.
@@ -22,6 +25,12 @@ func New() *Metrics {
// Name: "greet_total",
// Help: "How many greeting requests processed",
// }, []string{}),
BuildInfo: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: Subsystem,
Name: "build_info",
Help: "Build Information",
}, []string{"version"}),
}
// prometheus.Register(