Skip to content

Commit

Permalink
Start metrics a bit later
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuratczyk committed Nov 26, 2024
1 parent f15e9c2 commit 56908c5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ func RootCmd() *cobra.Command {
if cmd.Use != "version" {
setUris(&cfg, cmd.Use)
}

metrics.RegisterMetrics(cfg.MetricTags)
metrics.RegisterCommandLineMetric(cfg, cfg.MetricTags)
metricsServer := metrics.GetMetricsServer()
metricsServer.Start()
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
mgmt.DeleteDeclaredQueues()
Expand Down Expand Up @@ -274,8 +269,6 @@ func RootCmd() *cobra.Command {
}

func start(cfg config.Config) {
join_cluster(cfg.ExpectedInstances, cfg.SyncName)

if cfg.ConsumerLatency != 0 && cfg.ConsumerProto == config.MQTT {
fmt.Printf("Consumer latency is not supported for MQTT consumers")
os.Exit(1)
Expand All @@ -286,6 +279,10 @@ func start(cfg config.Config) {
os.Exit(1)
}

join_cluster(cfg.ExpectedInstances, cfg.SyncName)

start_metrics(cfg)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down Expand Up @@ -438,6 +435,13 @@ func join_cluster(expectedInstance int, serviceName string) {
}()
}

func start_metrics(cfg config.Config) {
metrics.RegisterMetrics(cfg.MetricTags)
metrics.RegisterCommandLineMetric(cfg, cfg.MetricTags)
metricsServer := metrics.GetMetricsServer()
metricsServer.Start()

}
func startConsumers(ctx context.Context, consumerProto config.Protocol, wg *sync.WaitGroup) {
for i := 1; i <= cfg.Consumers; i++ {
subscribed := make(chan bool)
Expand Down

0 comments on commit 56908c5

Please sign in to comment.