feat: Add metrics
All checks were successful
/ pre-commit (push) Successful in 1m40s

Fixes #7.

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2025-08-26 09:25:10 +02:00
parent e486d3df98
commit 0ce540e92d
Signed by: jriou
GPG key ID: 9A099EDA51316854
7 changed files with 141 additions and 18 deletions

View file

@ -7,6 +7,7 @@ import (
"git.riou.xyz/jriou/coller/internal"
"git.riou.xyz/jriou/coller/server"
"github.com/prometheus/client_golang/prometheus"
)
var (
@ -75,6 +76,16 @@ func handleMain() int {
srv.SetIDLength(config.IDLength)
srv.SetPasswordLength(config.PasswordLength)
if config.EnableMetrics {
reg := prometheus.NewRegistry()
metrics, err := server.NewMetrics(logger, reg, config, db)
if err != nil {
logger.Error("could not register metrics", slog.Any("error", err))
return internal.RC_ERROR
}
srv.SetMetrics(metrics)
}
err = srv.Start()
if err != nil {
logger.Error("could not start server", slog.Any("error", err))