According to Eurogamer, collecting every ring in a bonus stage earns you a 'Perfect', which is required for getting a Gold Metal.
The trick to getting a Perfect is to collect every ring on a stage.
You may notice you can finish a stage without collecting all the
rings, despite seemingly collecting all you can see; that's because
you can convert spheres into rings by creating an outline around
groups of blue spheres. These can be squares or rectangles, groups
that already have partial outlines already completed, or have unusual
shapes, such as bouncing spheres cutting into the corners.
The trick, then, is to make sure you have converted all
groups of blue spheres into rings before you collect any remaining
individual blue spheres. The easiest way to do this is to leave behind
one or two blue spheres that cannot be converted, getting the
'Perfect', then going back to those spheres you left.
It's worth noting that, as mentioned in our Sonic Mania unlockables
page, getting all gold medals doesn't unlock anything in game - only
Silvers is required. It's only if you want all Trophies or
Achievements that Gold is worth aiming for.
Screenshot from Giantbomb's 'Quick Look: Sonic Mania'