diff --git a/pkg/config/redis.go b/pkg/config/redis.go index 88db519e..645028ef 100644 --- a/pkg/config/redis.go +++ b/pkg/config/redis.go @@ -66,6 +66,12 @@ func dialWithLogging(logger *zap.SugaredLogger) func(context.Context, string, st logger.Warnw("Can't connect to Redis. Retrying", zap.Error(err)) } }, + OnSuccess: func(elapsed time.Duration, attempt uint64, _ error) { + if attempt > 0 { + logger.Infow("Reconnected to Redis", + zap.Duration("after", elapsed), zap.Uint64("attempts", attempt+1)) + } + }, }, ) diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index 31fba21e..462ab294 100644 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -39,6 +39,12 @@ func (c RetryConnector) Connect(ctx context.Context) (driver.Conn, error) { c.driver.Logger.Warnw("Can't connect to database. Retrying", zap.Error(err)) } }, + OnSuccess: func(elapsed time.Duration, attempt uint64, _ error) { + if attempt > 0 { + c.driver.Logger.Infow("Reconnected to database", + zap.Duration("after", elapsed), zap.Uint64("attempts", attempt+1)) + } + }, }, ), "can't connect to database") return conn, err