mirror of
https://github.com/NotAShelf/watchdog.git
synced 2026-03-07 05:46:00 +00:00
various: add internal health and runtime metrics
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Iae1dcf8495a00159d588c6e2344312f36a6a6964
This commit is contained in:
parent
d7cdf2cc49
commit
27b3641717
5 changed files with 187 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue