I don't know what your Doc is going to say and I'm sure he or she is wiser than me. I like the gym and even do light, very light weight work.
I would never just give up going to the gym but I test to see what workout or machines or activities end up causing discomfort. I try to build a routine. That is only one thing for a mont, then add something new so if there's a problem I can establish cause and effect and remove the new addition to my routine. and so on.
A class that varies each week doesn't give you enough feedback to let you determin e what is causing the pain. Is it one exercise, exercise in general or a few of the exercises.