Skip to content

Commit

Permalink
Error immediately when metrics export server fails
Browse files Browse the repository at this point in the history
Signed-off-by: joshvanl <me@joshvanl.dev>
  • Loading branch information
JoshVanL committed Oct 11, 2023
1 parent fa55f33 commit 19260d6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/metrics/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,14 @@ func (m *promMetricsExporter) startMetricServer(ctx context.Context) error {
errCh <- nil
}()

<-ctx.Done()
var err error
select {
case <-ctx.Done():
case err = <-errCh:
close(errCh)

Check warning on line 123 in pkg/metrics/exporter.go

View check run for this annotation

Codecov / codecov/patch

pkg/metrics/exporter.go#L119-L123

Added lines #L119 - L123 were not covered by tests
}

ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
return errors.Join(m.server.Shutdown(ctx), <-errCh)
return errors.Join(m.server.Shutdown(ctx), err, <-errCh)

Check warning on line 128 in pkg/metrics/exporter.go

View check run for this annotation

Codecov / codecov/patch

pkg/metrics/exporter.go#L128

Added line #L128 was not covered by tests
}

0 comments on commit 19260d6

Please sign in to comment.