add version command and add build information to metrics

Signed-off-by: David Christofas <dchristofas@owncloud.com>
This commit is contained in:
David Christofas
2020-09-25 16:41:02 +02:00
parent cae6a1c3ac
commit 116ba347e9
14 changed files with 129 additions and 20 deletions
+8 -2
View File
@@ -2,6 +2,7 @@ package command
import (
"context"
"github.com/owncloud/ocis/settings/pkg/metrics"
"os"
"os/signal"
"strings"
@@ -128,16 +129,20 @@ func Server(cfg *config.Config) *cli.Command {
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
mtrcs = metrics.New()
)
defer cancel()
mtrcs.BuildInfo.WithLabelValues(cfg.Service.Version).Set(1)
{
server := http.Server(
http.Name("settings"),
http.Name(cfg.Service.Name),
http.Logger(logger),
http.Context(ctx),
http.Config(cfg),
http.Metrics(mtrcs),
http.Flags(flagset.RootWithConfig(cfg)),
http.Flags(flagset.ServerWithConfig(cfg)),
)
@@ -153,10 +158,11 @@ func Server(cfg *config.Config) *cli.Command {
{
server := grpc.Server(
grpc.Name("settings"),
grpc.Name(cfg.Service.Name),
grpc.Logger(logger),
grpc.Context(ctx),
grpc.Config(cfg),
grpc.Metrics(mtrcs),
)
gr.Add(server.Run, func(_ error) {