various: add internal health and runtime metrics

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Iae1dcf8495a00159d588c6e2344312f36a6a6964
This commit is contained in:
raf 2026-03-02 21:38:43 +03:00
commit 27b3641717
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
5 changed files with 187 additions and 4 deletions

View file

@ -11,8 +11,11 @@ import (
)
var (
cfgFile string
cfg *config.Config
cfgFile string
cfg *config.Config
version string
commit string
buildDate string
)
var rootCmd = &cobra.Command{
@ -84,7 +87,8 @@ func initConfig() {
}
}
func Main() {
func Main(v, c, bd string) {
version, commit, buildDate = v, c, bd
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)

View file

@ -17,6 +17,7 @@ import (
"notashelf.dev/watchdog/internal/aggregate"
"notashelf.dev/watchdog/internal/api"
"notashelf.dev/watchdog/internal/config"
"notashelf.dev/watchdog/internal/health"
"notashelf.dev/watchdog/internal/limits"
"notashelf.dev/watchdog/internal/normalize"
)
@ -55,6 +56,12 @@ func Run(cfg *config.Config) error {
metricsAgg.MustRegister(promRegistry)
promRegistry.MustRegister(blockedRequests)
// Register health and runtime metrics
healthCollector := health.NewCollector(version, commit, buildDate)
if err := healthCollector.Register(promRegistry); err != nil {
return fmt.Errorf("failed to register health metrics: %w", err)
}
// Create HTTP handlers
ingestionHandler := api.NewIngestionHandler(
cfg,