Skip to content

Commit

Permalink
Prevent panic on --help
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuratczyk committed Sep 3, 2024
1 parent 5f0c319 commit 3e4a5a5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ func (m *MetricsServer) PrintMessageRates(ctx context.Context) {
}

func (m *MetricsServer) PrintFinalMetrics() {
// this might ve called before the metrics were registered
// eg. by `omq --help`
if MessagesPublished == nil {
return
}

log.Print("TOTAL PUBLISHED",
"messages", MessagesPublished.Get(),
"rate", fmt.Sprintf("%.2f/s", float64(MessagesPublished.Get())/time.Since(m.started).Seconds()))
Expand Down

0 comments on commit 3e4a5a5

Please sign in to comment.