Get JobId without PerformContext

To get JobId there are many sample that said get JobId from PerformContext,
But suppose there are many failed jobs in Dashboard and you need to resolved them by a new patch and don’t want to change the method signature and pass the PerformContext,
I have a method like

public static void OptimizerEX(string caption)

for backward compatibility I change the signature like to get JobId
public static void OptimizerEX(string caption, PerformContext context = null)
string currentJobId = context.BackgroundJob.Id;

but that raised null exception because 'context` is null,

So I am looking to get JobId or RetryCount without changing the signature.


Is there any solution to do this?