chore: rework prometheus metrics registration
fail if metric registration panics Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
This commit is contained in:
parent
3e025dda2f
commit
17d74dfbf0
11 changed files with 68 additions and 74 deletions
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/cloudbase/garm/config"
|
||||
"github.com/cloudbase/garm/database"
|
||||
"github.com/cloudbase/garm/database/common"
|
||||
"github.com/cloudbase/garm/metrics"
|
||||
"github.com/cloudbase/garm/runner"
|
||||
runnerMetrics "github.com/cloudbase/garm/runner/metrics"
|
||||
garmUtil "github.com/cloudbase/garm/util"
|
||||
|
|
@ -219,6 +220,11 @@ func main() {
|
|||
slog.InfoContext(ctx, "setting up metric routes")
|
||||
router = routers.WithMetricsRouter(router, cfg.Metrics.DisableAuth, metricsMiddleware)
|
||||
|
||||
slog.InfoContext(ctx, "register metrics")
|
||||
if err := metrics.RegisterMetrics(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
slog.InfoContext(ctx, "start metrics collection")
|
||||
runnerMetrics.CollectObjectMetric(ctx, runner, time.NewTicker(cfg.Metrics.Duration()))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue