Skip to content

Commit

Permalink
Don't print message rates until > 0
Browse files Browse the repository at this point in the history
This prevents printing zeros every second
if the clients can't even connect
  • Loading branch information
mkuratczyk committed Nov 30, 2024
1 parent 18d67ed commit c8ebc8f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ func (m *MetricsServer) PrintMessageRates(ctx context.Context) {
published := MessagesPublished.Get()
consumed := MessagesConsumedNormalPriority.Get() + MessagesConsumedHighPriority.Get()

log.Print("",
"published", fmt.Sprintf("%v/s", published-previouslyPublished),
"consumed", fmt.Sprintf("%v/s", consumed-previouslyConsumed))

previouslyPublished = published
previouslyConsumed = consumed

if published > 0 || consumed > 0 {
log.Print("",
"published", fmt.Sprintf("%v/s", published-previouslyPublished),
"consumed", fmt.Sprintf("%v/s", consumed-previouslyConsumed))

previouslyPublished = published
previouslyConsumed = consumed
}
}
}
}()
Expand Down

0 comments on commit c8ebc8f

Please sign in to comment.