From b6407936c8437b3d73dc5a43a504b45b40ddf365 Mon Sep 17 00:00:00 2001 From: Saswata Mukherjee Date: Mon, 21 Oct 2024 12:30:20 +0530 Subject: [PATCH] Implement suggestions Signed-off-by: Saswata Mukherjee --- cmd/avalanche/avalanche.go | 9 ++++----- metrics/write.go | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/avalanche/avalanche.go b/cmd/avalanche/avalanche.go index 0041b37..0e8b69e 100644 --- a/cmd/avalanche/avalanche.go +++ b/cmd/avalanche/avalanche.go @@ -61,22 +61,21 @@ func main() { cfg := metrics.NewConfigFromFlags(kingpin.Flag) port := kingpin.Flag("port", "Port to serve at").Default("9001").Int() - remoteWriteConfig := metrics.NewRemoteWriteConfigFromFlags(kingpin.Flag) + remoteWriteConfig := metrics.NewWriteConfigFromFlags(kingpin.Flag) kingpin.Parse() if err := cfg.Validate(); err != nil { kingpin.FatalUsage("configuration error: %v", err) } + if err := remoteWriteConfig.Validate(); err != nil { + kingpin.FatalUsage("remote write config validation failed: %v", err) + } collector := metrics.NewCollector(*cfg) reg := prometheus.NewRegistry() reg.MustRegister(collector) remoteWriteConfig.UpdateNotify = collector.UpdateNotifyCh() - if err := remoteWriteConfig.Validate(); err != nil { - kingpin.FatalUsage("remote write config validation failed: %v", err) - } - log.Println("initializing avalanche...") var g run.Group diff --git a/metrics/write.go b/metrics/write.go index 2872518..59767fc 100644 --- a/metrics/write.go +++ b/metrics/write.go @@ -57,7 +57,7 @@ type ConfigWrite struct { Concurrency int } -func NewRemoteWriteConfigFromFlags(flagReg func(name, help string) *kingpin.FlagClause) *ConfigWrite { +func NewWriteConfigFromFlags(flagReg func(name, help string) *kingpin.FlagClause) *ConfigWrite { cfg := &ConfigWrite{} flagReg("remote-url", "URL to send samples via remote_write API."). URLVar(&cfg.URL)