Skip to content

Commit

Permalink
Fix don't wait to collect metrics for the first time (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
boreq authored Nov 13, 2023
1 parent 22f91fe commit d338b3a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions service/ports/timer/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ func NewMetrics(app app.Application, logger logging.Logger) *Metrics {

func (m *Metrics) Run(ctx context.Context) error {
for {
if err := m.collect(ctx); err != nil {
m.logger.Error().WithError(err).Message("error triggering app handler")
}

select {
case <-time.After(collectMetricsEvery):
if err := m.collect(ctx); err != nil {
m.logger.Error().WithError(err).Message("error triggering app handler")
}
continue
case <-ctx.Done():
return ctx.Err()
}
Expand Down

0 comments on commit d338b3a

Please sign in to comment.