Skip to content

Commit

Permalink
Error immediately when metrics export server fails (#7021)
Browse files Browse the repository at this point in the history
Signed-off-by: joshvanl <me@joshvanl.dev>
Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
  • Loading branch information
JoshVanL and dapr-bot committed Oct 13, 2023
1 parent c4284d3 commit b6540a1
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)
}

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)
}

0 comments on commit b6540a1

Please sign in to comment.