Skip to content

Commit

Permalink
Fixed log message for prometheus server (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanprodanj authored May 8, 2022
1 parent 4b074ef commit 43c0934
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utils/metrics/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ func serveMetrics(ctx context.Context, logger *zap.Logger, listen string) {
go func(ctx context.Context, server *http.Server) {
<-ctx.Done()

if err := server.Shutdown(ctx); err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Warn("failure shutting down prometheus server", zap.Error(err))
if err := server.Shutdown(ctx); err != nil && !errors.Is(err,
http.ErrServerClosed) && !errors.Is(err, context.Canceled) {
logger.Warn("failed to shut down prometheus server", zap.Error(err))
}
}(ctx, server)

logger.Warn("prometheus server", zap.Error(server.ListenAndServe()))
err := server.ListenAndServe()
if err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Warn("failed to start prometheus server", zap.Error(err))
}
}

0 comments on commit 43c0934

Please sign in to comment.